fix(430): ESC intermittently not working in Safari #431
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #430. cc @steven-tey
There's a weird issue, probably related to Safari's
:focus-visible
behavior or their<dialog>
implementation, where the<dialog>
element's button doesn't receive focus when it's opened. It could also be a race condition because of the animation.Regardless, let's try listening for
Escape
at thedocument
level when we zoom an image. We need to make sure we provide theuseCapture
option and get to the event first so we can intercept it and don't trigger the default<dialog>
Escape
behavior so we can animate zooming out.Testing
In your project
react-medium-image-zoom@5.1.7-rc.0
Escape
when the images are zoomed!Using a clone of this project
npm i && npm start
Escape
when the images are zoomed!