[Bug]: Dialog errors when used in a React routing framework
See original GitHub issueWhat package within Headless UI are you using?
What version of that package are you using?
1.2.0
What browser are you using?
Firefox
Reproduction repository
React Router: https://codesandbox.io/s/mystifying-pond-0r5jv?file=/src/App.js Reach Router: https://codesandbox.io/s/jovial-euler-92zzn?file=/src/App.js
Describe your issue
When using either of the above routing frameworks, when navigating to a different page that renders a Dialog, the Dialog portal seems to get removed - resulting in the error:
There are no focusable elements inside the <FocusTrap />
To reproduce, one can observe the portal in the DOM on refresh, and on clicking a link to navigate to another page (which contains a modal) the portal gets removed from the DOM.
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:19
- Comments:8
Top Results From Across the Web
Problem with DialogComponent and react-router-dom
We have validated the issue, the Dialog is rendered by default with document.body as target. The console error “NotFoundError: Node was not ...
Read more >Error Handling in React 16 – React Blog
Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.
Read more >React Js Redux with .net core 2.1 Framework error
Like the error says, identify the component that is undefined by the line numbers given and check if you imported it correctly and...
Read more >Building a modal module for React with React-Router
We'll use four components from this package: BrowserRouter, Route, Link, and Switch. Since this is not a react-router tutorial, I won't be ...
Read more >How to work with React the right way to avoid some common ...
The “setState warning” exists to help you catch bugs, because calling setState() on an unmounted component is an indication that your app/ ...
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 Free
Top 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
Hi all,
I made a small reproduction demo repo for this issue using next, tailwind, and
@headlessui/react
.Edit:
I did end up finding a workaround. Adding the Dialog on mount seems to help this situation. See this branch in the same repo above for an example.
Hey! Thank you for your bug report! Much appreciated! 🙏
This should be fixed and is available in the latest version, just update to the latest version and it should start working. Here is an updated codesandbox: https://codesandbox.io/s/zen-phoebe-hzy7i