theKashey / react-focus-lock

It is a trap! A lock for a Focus. 🔓
MIT License
1.25k stars 65 forks source link

Returning focus to element inside an iframe #296

Closed spatel49 closed 1 month ago

spatel49 commented 3 months ago

Hey there!

I hope you're doing well. I just wanted to inform you of an issue we're facing with unexpected focus behavior when upgrading our react-focus-lock package from 2.11.2 to 2.9.3.

The problem we’re seeing is that the iframe document unexpectedly scrolls to the top of the page after closing certain modals, because it tries to return focus to the iframe element, and then focuses the header element (the first focusable node in the document). Ideally, it should look through the iframe when it’s determining what the active element is when the focus lock is first set up.

theKashey commented 3 months ago

🤔 Correct, the current return focus logic is not "entering" iframes and/or shadow dom, so cannot properly return element where it belongs. That should not be affected by the version change as return focus always was operating within a single document.

Anyway, tell me how exactly one can reproduce the problem?

stale[bot] commented 1 month ago

This issue has been marked as "stale" because there has been no activity for 2 months. If you have any new information or would like to continue the discussion, please feel free to do so. If this issue got buried among other tasks, maybe this message will reignite the conversation. Otherwise, this issue will be closed in 7 days. Thank you for your contributions so far.