-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Fix text selection edge scrolling when inside a horizontal scrollable #140250
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
Conversation
39bc576 to
7c9d1b7
Compare
127e1ba to
81e176f
Compare
81e176f to
e8b6bec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A way we can avoid having these overrides in selectable_text.dart so we can use the logic already in text_selection.dart is to use editableText.readOnly to differentiate between SelectableText and EditableText at the TextSelectionGestureDetector level. Not sure if we want to do this since maybe a user of TextField/EditableText might set readOnly to true and question why their gestures are behaving differently.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the behavior difference exactly?
It's not too much code to be concerning, but either way I can't wait to unify these so we don't have to think about problems like this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main difference is that on iOS a long press on static text select word-by-word, and on editable text it moves the collapsed cursor to the position.
On all other platforms (Android) a long press selects word-by-word.
e8b6bec to
e7f6fd8
Compare
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Still debating your question in https://github.com/flutter/flutter/pull/140250/files#r1446817469 but I think it's fine either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the behavior difference exactly?
It's not too much code to be concerning, but either way I can't wait to unify these so we don't have to think about problems like this!
| ? Offset(renderEditable.offset.pixels - _dragStartViewportOffset, 0.0) | ||
| : Offset(0.0, renderEditable.offset.pixels - _dragStartViewportOffset); | ||
| final double effectiveScrollPosition = _scrollPosition - _dragStartScrollOffset; | ||
| final bool scrollingOnVerticalAxis = _scrollDirection == AxisDirection.up || _scrollDirection == AxisDirection.down; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: would this be nicer as a switch or am I just overly excited to use switch everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a switch would work but might be a little verbose for this specific case. I think the logical comparison is clear and concise enough for this case.
final bool scrollingOnVerticalAxis = switch (_scrollDirection) {
AxisDirection.up => true,
AxisDirection.down => true,
AxisDirection.right => false,
AxisDirection.left => false,
};|
|
||
| final TestGesture gesture = | ||
| await tester.startGesture(selectableTextStart + const Offset(200.0, 0.0)); | ||
| await tester.pump(const Duration(milliseconds: 500)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe use kLongPressTimeout.
Roll Flutter from 19b06f4 to a8efa77 (38 revisions) flutter/flutter@19b06f4...a8efa77 2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from e2014f007f61 to 7c4ed15cb271 (1 revision) (flutter/flutter#142221) 2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from 5fa2e2920274 to e2014f007f61 (1 revision) (flutter/flutter#142213) 2024-01-25 andrewrkolos@gmail.com provide command to `FakeCommand::onRun` (flutter/flutter#142206) 2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from c346fd3d9ca1 to 5fa2e2920274 (1 revision) (flutter/flutter#142212) 2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from d4d8f668159b to c346fd3d9ca1 (1 revision) (flutter/flutter#142209) 2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from 499ed00bbda2 to d4d8f668159b (2 revisions) (flutter/flutter#142205) 2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4880592ca5ba to 499ed00bbda2 (6 revisions) (flutter/flutter#142202) 2024-01-25 ditman@gmail.com [ci] Adds test for web hot restart with const App. (flutter/flutter#141824) 2024-01-25 godofredoc@google.com Migrate android_view to linux_android_emu platform. (flutter/flutter#142184) 2024-01-25 matanlurey@users.noreply.github.com Refactor `external_ui` without making any name changes (I think) (flutter/flutter#142192) 2024-01-25 rmolivares@renzo-olivares.dev Fix text selection edge scrolling when inside a horizontal scrollable (flutter/flutter#140250) 2024-01-25 engine-flutter-autoroll@skia.org Roll Flutter Engine from d7bf5ec1dcdd to 4880592ca5ba (2 revisions) (flutter/flutter#142186) 2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6a7f963dc751 to d7bf5ec1dcdd (2 revisions) (flutter/flutter#142185) 2024-01-24 polinach@google.com Reland "Remove hack from PageView." (flutter/flutter#142172) 2024-01-24 polinach@google.com Upgrade leak_tracker. (flutter/flutter#142162) 2024-01-24 godofredoc@google.com Migrate android views to devicelab. (flutter/flutter#142081) 2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from ed498f111d53 to 6a7f963dc751 (4 revisions) (flutter/flutter#142176) 2024-01-24 jaeyoi.dev@gmail.com Support wireless debugging for iOS 12 or earlier (flutter/flutter#141439) 2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4bc368ee5f74 to ed498f111d53 (5 revisions) (flutter/flutter#142167) 2024-01-24 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Refactor `external_ui` � `external_textures`" (flutter/flutter#142173) 2024-01-24 matanlurey@users.noreply.github.com Refactor `external_ui` � `external_textures` (flutter/flutter#142062) 2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from 0b9fce355df9 to 4bc368ee5f74 (3 revisions) (flutter/flutter#142157) 2024-01-24 jhy03261997@gmail.com Update navigationBar label's maxScaleFactor to meet GAR requirement (flutter/flutter#141998) 2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from b65556fa543e to 0b9fce355df9 (1 revision) (flutter/flutter#142147) 2024-01-24 fluttergithubbot@gmail.com Marks Mac_arm64 build_tests_2_4 to be unflaky (flutter/flutter#142115) 2024-01-24 fluttergithubbot@gmail.com Marks Mac_x64 build_tests_2_4 to be unflaky (flutter/flutter#142111) 2024-01-24 fluttergithubbot@gmail.com Marks Mac_x64 build_tests_1_4 to be unflaky (flutter/flutter#142110) 2024-01-24 fluttergithubbot@gmail.com Marks Mac_x64 build_tests_3_4 to be unflaky (flutter/flutter#142112) 2024-01-24 greg@zulip.com Revise tooltip theme docs, including more cross-references (flutter/flutter#137316) 2024-01-24 godofredoc@google.com Run some tests explicitly in both arm and x64. (flutter/flutter#141910) 2024-01-24 engine-flutter-autoroll@skia.org Roll Flutter Engine from ba3a70ce7722 to b65556fa543e (3 revisions) (flutter/flutter#142140) 2024-01-24 31859944+LongCatIsLooong@users.noreply.github.com Fixes #138773, port autocomplete to OverlayPortal (flutter/flutter#140285) 2024-01-24 jesus_sguerrero@hotmail.com Revert "[web] - Fix broken `TextField` in semantics mode when it's a sibling of `Navigator`" (flutter/flutter#142129) 2024-01-24 fluttergithubbot@gmail.com Marks Mac_arm64 build_tests_1_4 to be unflaky (flutter/flutter#142114) 2024-01-24 engine-flutter-autoroll@skia.org Roll Packages from 841fe90 to 8fbdf65 (2 revisions) (flutter/flutter#142139) 2024-01-24 fluttergithubbot@gmail.com Marks Mac_arm64 build_tests_3_4 to be unflaky (flutter/flutter#142116) 2024-01-24 fluttergithubbot@gmail.com Marks Mac_x64 build_tests_4_4 to be unflaky (flutter/flutter#142113) 2024-01-24 fluttergithubbot@gmail.com Marks Mac_arm64 build_tests_4_4 to be unflaky (flutter/flutter#142117) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC bmparr@google.com,rmistry@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose ...
Fixes #129590
AxisDirectionwhen calculating scroll offset used in determining TextSelection during a drag/long press drag. Previously it seems that we were assuming the direction was always verticalflutter/packages/flutter/lib/src/widgets/text_selection.dart
Lines 2842 to 2844 in 30cc831
Pre-launch Checklist
///).