Skip to content

Refactoring of SelectionChangedCause needed #26026

Closed

Description

@jslavitz

Currently the selection changed cause (used in text_field.dart) is used to specify whether or not we want the toolbar to appear after the selection changes. Now that there are many different types of gestures that we use to change selection, it would make more sense to simply directly specify whether we want the toolbar to appear instead of indirectly specifying a selection changed cause.

Activity

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    p: cupertino_uicupertino_ui package in flutter/packages
    on Jan 3, 2019
  2. jslavitz commented on Jan 3, 2019

    @jslavitz
    ContributorAuthor

    We've decided to just let this be for now as SelectionChangedCause is written pretty deep in the code base.

  3. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    on Jan 17, 2019
  4. xster commented on Jan 18, 2019

    @xster
    Member

    I'm gonna re-open this following some offline discussions to hopefully clean up the APIs a bit. cc @HansMuller @justinmc @Hixie

    The problem we're trying to solve is that there's ~60 places in code where we're sending this enum around. Most of the creations and inputs leading into the creation of this enum originate from (Cupertino)TextField. They pipe through the widget and rendering layer into RenderEditable and then bubble back out through EditableTextState back to the TextField. In the end, they're read in 3 places to vibrate, show the toolbar and show the selection handles.

    EditableText and RenderEditable should be a simple, bare and composable API that's agnostic to what these touch events are and when to respond to them. They should just have APIs like selectPosition, selectWord, showToolbar etc.

    Reactions to gesture events are very platform specific and the layers above EditableText that want to cause effects to gesture events should just invoke those effects directly.

    • Add tons of tests for all existing behaviors and APIs around TextField, CupertinoTextField, EditableText and RenderText
    • Draft a plan for a soft-API-break migration to remove SelectionChangeCause
    • Submit to flutter-announce for feedback
    • Refactor
    • Create an intermediate layer for adherence to platform gesture touch conventions between Material/Cupertino and EditableText for developers who want to create a custom text field.
  5. reopened this on Jan 18, 2019
  6. self-assigned this
    on Jan 18, 2019
  7. github-actions commented on Aug 30, 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.

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

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.p: cupertino_uicupertino_ui package in flutter/packagesp: material_uimaterial_ui package in flutter/packages

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions