Skip to content
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

Focus Trap not working in Safari with Link #1050

Open
mattpen opened this issue Aug 7, 2024 · 0 comments
Open

Focus Trap not working in Safari with Link #1050

mattpen opened this issue Aug 7, 2024 · 0 comments

Comments

@mattpen
Copy link

mattpen commented Aug 7, 2024

Summary:

Focus Trap not working in Safari with Link

If you create a modal, and the first element is a link (<a>), then focus can escape if you are using Safari and you either (a) did not enable the setting "Press Tab to highlight each item on a webpage" or (b) are not using Option+Tab to navigate. It looks like since the browser skips focus on that link that the focus trap listeners don't ever get a chance to fire.

Steps to reproduce:

  1. Create a simple ReactModal with a link and a button:
<button>Outer Button</button>
<Modal isOpen={true}>
   <a href="https://https://github.com/reactjs/react-modal/">Click this link!</a>
   <button>Inner Button</button>
</Modal>
  1. In Safari's Settings / Advanced, uncheck "Press Tab to highlight each item on a webpage".
  2. Open the modal, the link is focused.
  3. Hit Tab, the Inner Button is focused.
  4. Hit Shift+Tab, the Outer Button is focused.

Expected behavior:

Focus should be trapped in modals on Safari no matter whether you are using Tab or Option Tab, despite your setting for "Press Tab to highlight each item on a webpage".

Link to example of issue:

https://codesandbox.io/s/react-modal-issue-template-forked-5kvtgx

Additional notes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant