Closed
Description
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
- Go to https://primer.style/react/Dialog
- Press the 'Escape' key
- See that focus goes to one of the 'open' buttons
Version
v35.28.0
Browser
Chrome