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

Dialogs hijack focus on 'escape' press when they aren't open #3686

Closed
jdrush89 opened this issue Aug 29, 2023 · 0 comments · Fixed by #3689
Closed

Dialogs hijack focus on 'escape' press when they aren't open #3686

jdrush89 opened this issue Aug 29, 2023 · 0 comments · Fixed by #3689
Labels
bug Something isn't working

Comments

@jdrush89
Copy link
Contributor

jdrush89 commented Aug 29, 2023

Description

If a dialog component is being rendered, but is closed, and the escape key is pressed, focus will get set to the dialog's target. This seems to be due to the logic that tries to set focus back to the last focused element when a dialog closes, but the logic should not be executing if the dialog was never opened.

Steps to reproduce

  1. Go to https://primer.style/react/Dialog
  2. Press the 'Escape' key
  3. See that focus goes to one of the 'open' buttons

Version

v35.28.0

Browser

Chrome

@jdrush89 jdrush89 added the bug Something isn't working label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant