Skip to content

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

Description

@gmoraja

@goderbauer
@gspencergoog
@lorenzOliveto

Steps to reproduce:

  • Attach a keyboard to an Android device
  • push multiple Widget in the navigator stack
  • going back to the root with Navigator.popUntil

The keyboard focus is lost and it doesn’t respond anymore. You can find an example in this repository, https://github.com/lorenzOliveto/flutter_keyboard_navigation_issues (pop_until_example.dart).

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    f: routesNavigator, Router, and related APIs.
    on Jan 15, 2020
  2. self-assigned this
    on Jan 28, 2020
  3. added this to the February 2020 milestone on Jan 29, 2020
  4. gmoraja commented on Feb 9, 2020

    @gmoraja
    Author

    @gspencergoog we tested this in the most recent master but we haven't noticed any difference in the behavior, should we open a new issue or wait for an update?

  5. chunhtai commented on Feb 10, 2020

    @chunhtai
    Contributor

    Taking a look

  6. chunhtai commented on Feb 10, 2020

    @chunhtai
    Contributor

    Ok, I found the issue, My fix does not fix all the possible use cases.
    Will put up another pr to make the focus traversal more robust

  7. goderbauer commented on Feb 19, 2020

    @goderbauer
    Member

    @gspencergoog Does #50831 fix this or how does it relate to this issue?

  8. gspencergoog commented on Feb 19, 2020

    @gspencergoog
    Contributor

    It incorporates part of @chunhtai's fix (finding a focusable parent to focus), but I should probably incorporate the test that @chunhtai created here into that PR too.

  9. gspencergoog commented on Feb 26, 2020

    @gspencergoog
    Contributor

    But yes, #50831 fixes this.

  10. HerrNiklasRaab commented on Apr 11, 2020

    @HerrNiklasRaab

    Hey @gspencergoog, this change seems to break this plugin, just try the example an move the KeyboardDismisser ouside the MaterialApp:
    https://github.com/drogel/keyboard_dismisser

    Is it intended, that unfocus doesn't work outside of the MaterialApp?

    I further described my problem there: drogel/keyboard_dismisser#1

  11. gspencergoog commented on Apr 13, 2020

    @gspencergoog
    Contributor

    @HerrNiklasRaab It looks like there is a fix for the keyboard_dismisser that works for the case you want.

    That particular change in the focus code was made because without a valid scope for the node requesting to be unfocused, there isn't a way to determine what the next focused node should be. Unfocus is not about losing focus, it's about transferring focus to another node, since there can't really be a case where nothing has focus, or focus traversal stops working.

    Because of this, you may notice that with keyboard_dismisser as it is now, that once the soft keyboard is dismissed, pressing TAB when there is a hardware keyboard connected will no longer move to the next available focus node until focus is explicitly given to a node that is in the focus tree.

    This may not matter to you, since you're clearly interested in the mobile experience, but it does matter in other contexts (e.g. on the web, or a desktop app).

  12. github-actions commented on Aug 22, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  13. locked as resolved and limited conversation to collaborators on Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: desktopRunning on desktopcustomer: soldierf: routesNavigator, Router, and related APIs.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions