Skip to content

Dismiss modal routes with a keyboard shortcut - #59310

Merged
fluttergithubbot merged 4 commits into
flutter:masterfrom
darrenaustin:keyboard_dismiss
Jun 18, 2020
Merged

fluttergithubbot merged 4 commits into
flutter:masterfrom
darrenaustin:keyboard_dismiss

Conversation

@darrenaustin

@darrenaustin darrenaustin commented Jun 12, 2020 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 p: material_ui material_ui package in flutter/packages 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.

@HansMuller HansMuller left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread packages/flutter/lib/src/widgets/actions.dart Outdated
Comment thread packages/flutter/lib/src/widgets/actions.dart Outdated

@HansMuller HansMuller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread packages/flutter/lib/src/widgets/actions.dart Outdated
Comment thread packages/flutter/lib/src/widgets/actions.dart Outdated

@gspencergoog gspencergoog left a comment

Copy link
Copy Markdown
Contributor

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

framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants