Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring of SelectionChangedCause needed #26026

Closed
jslavitz opened this issue Jan 3, 2019 · 3 comments
Closed

Refactoring of SelectionChangedCause needed #26026

jslavitz opened this issue Jan 3, 2019 · 3 comments
Assignees
Labels
a: text input Entering text in a text field or keyboard related problems f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Comments

@jslavitz
Copy link
Contributor

jslavitz commented Jan 3, 2019

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.

@jslavitz jslavitz added a: text input Entering text in a text field or keyboard related problems f: cupertino flutter/packages/flutter/cupertino repository labels Jan 3, 2019
@jslavitz
Copy link
Contributor Author

jslavitz commented Jan 3, 2019

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

@jslavitz jslavitz closed this as completed Jan 3, 2019
@xster xster added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Jan 17, 2019
@xster
Copy link
Member

xster commented Jan 18, 2019

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.

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: text input Entering text in a text field or keyboard related problems f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

No branches or pull requests

2 participants