MDC-Web: Dialog "You can't have a focus-trap without at least one focusable element"
See original GitHub issueI’m using <script src="//unpkg.com/material-components-web@latest/dist/material-components-web.min.js"></script>
w foundation and today am getting an error that I was not getting last week.
material-components-web.min.js:6 Uncaught Error: You can't have a focus-trap without at least one focusable element
at p (material-components-web.min.js:6)
at l (material-components-web.min.js:6)
at Object.n [as activate] (material-components-web.min.js:6)
at Object.trapFocusOnSurface (material-components-web.min.js:6)
at e.value (material-components-web.min.js:6)
at HTMLDivElement.n.transitionEndHandler_ (material-components-web.min.js:6)
Any ideas? I have a <button id="account-cancel" type="button" class="mdc-button mdc-dialog__footer__button mdc-dialog__footer__button--cancel">Cancel</button>
in the dialog?..
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (5 by maintainers)
Top Results From Across the Web
FocusTrap: Element must have at least one focusable child ...
Make sure that your dialog ( .mdc-dialog ) is actually injected in the DOM, and that it contains at least one element a...
Read more >ERROR Error: You can't have a focus-trap without at least one ...
I got this error in my Angular code for opening a material design dialog(MDCDialog), but I have no clue at the first glance....
Read more >Showing a dialog with no buttons prints an error in console (You can ...
Showing a dialog with no buttons prints an error in console (You can't have a focus-trap without at least one focusable element)
Read more >there are no focusable elements inside the <FocusTrap />
This error was being thrown when I tried to use the Simpler Alert Modal of TailwindUI. After googling, the ff resources helped me...
Read more >How to use the focus-trap function in focus-trap - Snyk
To help you get started, we've selected a few focus-trap examples, ... needs to have at least one focusable element') { console.log('Focus trap...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Download I found a solution to the problem - you must have at least one
DrawerItem
with theselected
attributeFor future reference I’m linking a complete example of dismissible drawer on stackblitz.
The reason we made it to have at least one focusable element inside drawer because of accessibility reasons.
As suggested above, it is recommended to have at least one drawer item (i.e.,
mdc-list-item
).@Download Please see this example for use case when none of the drawer items are selected initially. Drawer component itself is not aware which navigation item is currently active, it is also not safe assumption to activate or select first item.