Skip to content

Conversation

@darrenaustin
Copy link
Contributor

@darrenaustin darrenaustin commented Jun 12, 2020

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 DismissIntent and corresponding DismissAction. The intent is mapped to the escape key 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

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I signed the [CLA].
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them?

  • No, no existing tests failed, so this is not a breaking change.

@fluttergithubbot
Copy link
Contributor

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.

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Jun 12, 2020
@darrenaustin darrenaustin marked this pull request as draft June 12, 2020 07:12
@gspencergoog
Copy link
Contributor

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.

@darrenaustin
Copy link
Contributor Author

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.

@fluttergithubbot fluttergithubbot added f: material design flutter/packages/flutter/material repository. work in progress; do not review labels Jun 12, 2020
@darrenaustin darrenaustin changed the title WIP: Modal DismissIntent/Action shortcut Dismiss modal routes with a keyboard shortcut Jun 12, 2020
@darrenaustin darrenaustin marked this pull request as ready for review June 12, 2020 20:57
@darrenaustin darrenaustin requested review from HansMuller, goderbauer and gspencergoog and removed request for gspencergoog June 12, 2020 20:57
… to reflect a more generic cancel/dismiss/back action.
Copy link
Contributor

@HansMuller HansMuller left a 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.

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants