Conversation
When the app closed the top modal on Escape keydown, the keyup of the same key press closed the modal underneath as well. A modal now closes only for a key press that began while it was the active modal and whose keydown was not handled.
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 95e2d84:
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When one dialog is open on top of another, pressing Escape once closes both instead of just the top one.
Test case: https://codesandbox.io/s/t85xr3 (Open settings, then Delete deck, then press Escape once. Both modals close.)
Change
A modal now closes on Escape
keyuponly when the same key press began while it was the active modal and itskeydownwas not handled (defaultPrevented). Thekeydownis recorded in the capture phase, so it is still seen when a focusedTextInputstops its propagation. Closing stays onkeyup, so:TextInputstill closes the modalTests
The existing Escape tests now send
keydownfollowed bykeyup, as a real key press does. New tests cover stacked modals with and without the app handling Escape, a focusedTextInput, holding Escape, a handledkeydown, and a key press that began before the modal was active.npm run format,npm run lintandnpm run unitpass.npm run flowreports no new errors.