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

Dialog doesn't restore focus to the trigger button on Safari #1643

Closed
diegohaz opened this issue Jul 5, 2022 · 4 comments · Fixed by #2326
Closed

Dialog doesn't restore focus to the trigger button on Safari #1643

diegohaz opened this issue Jul 5, 2022 · 4 comments · Fixed by #2326
Assignees

Comments

@diegohaz
Copy link

diegohaz commented Jul 5, 2022

What package within Headless UI are you using?

@headlessui/react, @headlessui/vue

What version of that package are you using?

latest on the site

What browser are you using?

Safari

Reproduction URL

https://headlessui.com/react/dialog

Describe your issue

  1. Open https://headlessui.com/react/dialog on Safari
  2. Close the dialog in the preview
  3. Click on the "Open dialog" button
  4. Press Esc
  5. Press Enter

Notice that the Dialog doesn't open again as it does on other browsers because the focus is not restored to the "Open dialog" button.

I believe this happens because Headless UI may be relying on buttons receiving focus when they get clicked to restore it when the dialog closes, but Safari doesn't focus on buttons on mouse down.

@RobinMalfait RobinMalfait self-assigned this Aug 1, 2022
@RobinMalfait RobinMalfait removed their assignment Aug 22, 2022
@juliantroeps
Copy link

juliantroeps commented Sep 13, 2022

@diegohaz @RobinMalfait I think this is by design from Apple. I cannot tab focus anywhere on any site if I don't allow it from Safari settings. See:
https://www.scottohara.me/blog/2014/10/03/link-tabbing-firefox-osx.html#make-sure-safari-is-appropriately-setup-too

@diegohaz
Copy link
Author

@juliantroeps That's not the same thing. That macOS option allows tabbing through links. Tabbing through buttons and other tabbable elements works as expected, even when that option is unchecked. The issue here is that Safari doesn't focus on buttons on mouse down, not when tabbing.

@Xiaobei-QuQ
Copy link

windows chrome version v72.0.3626.81 experiencing the same problem

@RobinMalfait
Copy link
Member

Hey, thank you for this bug report! 🙏

This should be fixed by #2326, and will be available in the next release.

You can already try it using:

  • npm install @headlessui/react@insiders.
  • npm install @headlessui/vue@insiders.

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

Successfully merging a pull request may close this issue.

4 participants