-
Notifications
You must be signed in to change notification settings - Fork 561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dialog: focus-trap blocks interactive elements rendered using portal #83
Comments
Interesting case. I think the right solution is to make your portal elements render inside the dialog component. It actually makes sense. The reason for rendering tooltips and popups as a direct child of body is usually either dealing with css specificity or z-index wars. And since you have a modal dialog open, you're already rendering your elements outside the main app root. There should be no need to render popups in a parallel branch. |
Yep, this is what I would do with my own components to solve the issue, but what about third party ones. For example react-semantic-ui Popup. Also, the reasoning behind putting something in a portal can be not only z-index, but also overflow positioning. |
I had similar problems with 3rd party libraries and I've came to the conclusion that those libs that do not let you configure the root container they attach to are not very good libraries :) And it is a good idea to open an issue in their repository. I understand that this is not the answer you were hoping for, but it seems to me to be the "right" way to deal with this. Also I wonder whether the |
What about making |
This might be relevant, checkout this article: It’s a (focus) Trap!
|
This is a super valid point. In an article I wrote how we manager layers and focus trap at work. Basically we activate the focus trap declaratively and the modal module exports a function that we can invoke imperatively to temporarily deactivate the trap for the element that |
react-focus-lock could be a solution here - it uses React event propagation, not DOM, thus focus events, as long as they would bubble from portals, are visible to lock, and are considered as their own. |
ah! this is likely the problem with #64, would love somebody to explore using react-focus-lock and send a PR using it? |
Probably that should be on me. |
We are facing currently same issue with |
I believe this issue has been resolved but simply not closed, but if folks are still having trouble here please flag me and I'll happily reopen and investigate further. |
So it works if you can "click" on portaled elements, and that would properly bubble from react tree, and managed, but in terms of "focus trapping" - there is no way you can "tab" into portaled content. |
No, this isn't solved yet. I've encountered the same focus trap issue in v0.15.2. If I assign I'm loading a third-party widget that appends a Update: @chaance's solution proposed in this comment, which is to set the Update 2: setting |
Hi, thanks for the
Dialog
. It works great but I face one issue. You are usingfocus-trap
internally to block events outside theDialog
, which is nice and I understand the logic behind this. I am rendering some interactive elements inside theDialog
and some of them are also using portals for rendering (for example popups), which results them being not a child node of theDialog
and this why not active. They are visible, but not clickable. Can you suggest some solution or workaround? I didn't come up with anything. Maybe it's possible to only block click events on the elements, that are above theDialog
in the DOM tree.The text was updated successfully, but these errors were encountered: