-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Dismiss modal routes with a keyboard shortcut #59310
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
Dismiss modal routes with a keyboard shortcut #59310
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
This looks pretty good. We'll need to make sure that it is the right thing for the web, but otherwise I think all platforms use escape in this way. |
Yeah, from a cursory look of a few webapps, it appears that escape to dismiss popups is pretty common. I'll go ahead and flush this out with docs and tests to get this ready for review. Any thoughts about putting this on the _ModalScope? It seemed like the best place to me, but I am not that familiar with the route code. |
… to reflect a more generic cancel/dismiss/back action.
HansMuller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just wanted to get a few small clarifications.
HansMuller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…e of the documentation.
gspencergoog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.

Description
Currently there is no support for dismissing modal routes with the keyboard (usually with the 'escape' shortcut key). This PR adds a new general
DismissIntentand correspondingDismissAction. The intent is mapped to theescapekey in the default shortcut map, and modal routes (dialogs, popups, drawers, etc) will now look for this and dismiss themselves when it is triggered.Related Issues
#49809
Tests
I added a simple test to verify that a modal dialog can be dismissed with the 'escape' key.
Checklist
///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them?