Skip to content

Preserve text field's caret position across focus changes #86752

Closed

Description

@LongCatIsLooong

Currently we set the selection and the composing range of a text field to empty when it loses focus (#10911):

_value = TextEditingValue(text: _value.text);

Steps to Reproduce

But on Android if you:

  1. go to a login screen
  2. type something in the password field, and move the caret to the middle of the string,
  3. select the username field (the caret should disappear), and use the "next" button on the virtual keyboard to focus the password field again
  4. As the password regains focus the caret re-appears, and it should be where it was.

GTK seems to have the same behavior, except it doesn't collapse the selection while android does (maybe it's the IME?). When you press tab to refocus an input field that previously has a non-collapsed selection, the selection will re-appear.

Dropping the selection also notifies the text field's TextEditingControllers listeners (#79982). Not commonly expected.

Activity

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    a: fidelityMatching the OEM platforms better
    P3Issues that are less important to the Flutter project
    on Jul 21, 2021
  2. github-actions commented on Aug 21, 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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: fidelityMatching the OEM platforms bettera: text inputEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions