Skip to content

Deprecate and remove FocusScope and FocusScopeNode #109896

@gspencergoog

Description

@gspencergoog

The FocusScopeNode serves two main purposes:

  1. It "scopes" the focus so that you can't escape the scope by tab traversal.
  2. It keeps a stack of previously focused widgets so that if you return focus to the scope, it will re-focus the widget that previously had focus inside of the scope.

The two jobs are pretty orthogonal to each other, and rather than give it even more "modes", it makes sense to split it into two things.

The FocusTraversalGroup is the proper place for a flag that would limit the tab traversal to within the group (the actual flag would be on FocusNode), and it would make sense to deprecate the remaining FocusScopeNode (and associated FocusScope widget) and replace it with something that just did the focus history piece (probably called FocusHistory for obvious reasons).

This would give us a chance to separate these concerns, and would let us simplify a lot of the weird knots that the focus API is wound into as a result of wanting to keep from breaking previous APIs.

cc @goderbauer

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listf: focusFocus traversal, gaining or losing focusframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions