Dismiss modal routes with a keyboard shortcut#59310
Dismiss modal routes with a keyboard shortcut#59310fluttergithubbot merged 4 commits intoflutter:masterfrom darrenaustin:keyboard_dismiss
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.
LGTM, just wanted to get a few small clarifications.
…e of the documentation.

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?