Skip to content

fix focus traversal after pages popped#49714

Merged
gspencergoog merged 1 commit intoflutter:masterfrom
chunhtai:issues/48903
Jan 30, 2020
Merged

fix focus traversal after pages popped#49714
gspencergoog merged 1 commit intoflutter:masterfrom
chunhtai:issues/48903

Conversation

@chunhtai
Copy link
Copy Markdown
Contributor

Description

There are two mechanism that traverse the focus in ModalRoute when a page pop, and they are not in sync and conflict with each other

if (widget.route.isCurrent) {

and

The first one request focus regardless the state of animation controller, while the second one enable focus based on the state of animation controller. This makes focus node traverse to a weird place when pops more than two pages.

for example, we have three pages in routes history
page1
page2
page3 <--- current focus

we pop page2 and page3 at the same time, as soon as the animation controller is reverse we trigger

if (widget.route.isCurrent) {

page3 will trigger first and then page2, the bring the focus to page2 before the animation has even starting the build the first frame.


will try to bring the focus from page3 to page2, and then page2 to page1. However, the focus is already on page2, and there are series of FocusNode marked dirty with nextnode = null which brings the focus to be on root focus node and cause this error.

Related Issues

fixes #48903

Tests

I added the following tests:

"focus traverse correct when pop mutiple page simultaneously"

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • 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? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change. If not, delete the remainder of this section.
    • I wrote a design doc: https://flutter.dev/go/template Replace this with a link to your design doc's short link
    • I got input from the developer relations team, specifically from: Replace with the names of who gave advice
    • I wrote a migration guide: Replace with a link to your migration guide

@chunhtai chunhtai requested a review from gspencergoog January 29, 2020 17:48
@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Jan 29, 2020
Copy link
Copy Markdown
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
Thanks!

@fluttergithubbot
Copy link
Copy Markdown
Contributor

This pull request is not suitable for automatic merging in its current state.

  • Please get at least one approved review before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@gspencergoog gspencergoog merged commit 406d8f7 into flutter:master Jan 30, 2020
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 1, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard focus is lost when popping multiple screens with Navigator.popuntil

4 participants