Thanks to visit codestin.com
Credit goes to github.com

Skip to content

How to share focus with popovers and other sub-tasks #106923

Open
@matthew-carroll

Description

@matthew-carroll

There's a conflict in text-based focus behavior in Flutter and I'm wondering if there's an intended approach to this problem.

Typically, when entering text into something like a form field, the moment focus moves away from the field, the selection is gone. For example, you'll see a caret and type text into a "name" field. Then, focus moves to an "email" field. At this point, there is no caret or selection in the "name" field any longer, and there is a caret in the "email" field. However, this focus behavior is not universal.

When composing text, there are a number of occasions in which some kind of popover might appear. For example, a popover to select text styles, enter a URL for a link, or select a compound character. In these situations, the popover includes focusable elements, and the user should be able to move focus around those elements. But that focus change should not impact the selection within the text field. Additionally, the moment the popover disappears, focus should return to the text field with the selection unchanged.

Does Flutter have an approach for handling these different situations?

Visual examples:

  • Editing the link URL in a selection toolbar (this example use SuperEditor but without keyboard as the input source, not IME)
    Screenshot 2022-06-28 at 23 46 13

  • Right-click on selected to show the context menu
    Screenshot 2022-06-28 at 23 49 08

  • Press and hold character key that can be written with different accents depending on the language (e.g. Portuguese)
    Screenshot 2022-06-28 at 23 50 53

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: text inputEntering text in a text field or keyboard related problemsc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterf: focusFocus traversal, gaining or losing focusf: material designflutter/packages/flutter/material repository.frameworkflutter/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