Doesn't seem to work in other documents
See original GitHub issueI appreciate the effort you have put into making the focus trap library work in iframes and child windows, but unfortunately it seems like maybe the React version is not prepared for this?
I’m using the FocusTrap like <FocusTrap active={element !== null} focusTrapOptions={{document}}>
, where document
is the document of the child window (derived from element.ownerDocument
), but the focus trap still isn’t trapping focus. When the same component is used in the main document, it works just fine.
Do you know what could be the cause of the issue?
Issue Analytics
- State:
- Created 2 years ago
- Comments:25 (15 by maintainers)
Top Results From Across the Web
Microsoft Word Not Responding? 8 Ways To Fix It
One way to fix this is to repair those corrupt documents and then open them with Word. Open Word on your computer. Use...
Read more >How to troubleshoot problems that occur when you start or ...
Provides a guide to identify and resolve problems that you experience when you start Word.
Read more >8 Ways to Fix the Grammarly Add-In Not Working in ...
Grammarly is great at detecting errors in your English, but sometimes it needs a little help with the Microsoft Word add-in on Windows....
Read more >Can't Save Edited Document - Word Ribbon Tips
Load the original file (not the copy you used Open and Repair with) and use Save As to save the document in different...
Read more >Microsoft Word Spell Check Not Working? (5 Solutions)
1. Click the File tab. 2. From the left menu, select Options at the bottom. 3. In the Word Options dialog, click Proofing....
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
That’s true. Then rendering with
<FocusTrap>
could cause the div to change, causing the ref to change, and I guess it could be a different document at that point, though that seems unlikely. Still, it wouldn’t be totally “clean” to assume it’s the same document.I’ll give this some thought. It’s a significant change in terms of when the trap gets created. I’ll have to check focus-trap to see if creating the trap triggers any events for which you might expect a callback in one of the options, in which case, you wouldn’t get the callback at the same time anymore.
If that turns out to be a problem, then another option might be to promote the
document
option to a prop (instead of nesting it infocusTrapOptions
where there’s no “notification” if it changes) and then re-create the trap if that prop changes. Then we could maintain existing behavior and only have changes affect changing thedocument
.So something like
componentDidMount()
, only callthis.setupFocusTrap()
ifthis.props.active
is true, and then incomponentDidUpdate()
, check if(!prevProps.active && this.props.active)
and callthis.setupFocusTrap()
(if it doesn’t already exist).