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
Fix edge scrolling on platforms that select word by word on long press move #113128
Fix edge scrolling on platforms that select word by word on long press move #113128
Conversation
| @@ -1561,7 +1561,7 @@ void main() { | |||
| expect(text.style!.fontWeight, FontWeight.w400); | |||
| }, skip: isContextMenuProvidedByPlatform); // [intended] only applies to platforms where we supply the context menu. | |||
|
|
|||
| testWidgets('text field toolbar options correctly changes options', (WidgetTester tester) async { | |||
| testWidgets('text field toolbar options correctly changes options on Apple Platforms', (WidgetTester tester) async { | |||
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.
FYI I'm deprecating toolbarOptions in my context menu PR. I worry that these tests might get deleted when toolbarOptions is removed a year from now. Maybe change the title to indicate that they're testing longpress behavior too? If you think they should not be deleted.
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 we can delete these tests with the deprecation. There are other tests that more implicitly test long press. This test also doesn't test for long press on apple platforms since they do not select a word on long press, only move the cursor.
| const TextSelection(baseOffset: 0, extentOffset: 7, affinity: TextAffinity.upstream), | ||
| ); | ||
|
|
||
| // non-Collapsed toolbar shows 3 buttons. |
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: Capitalize the first letter.
| expect(find.byKey(fakeMagnifier.key!), findsNothing); | ||
| }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android })); | ||
|
|
||
| testWidgets('Can long press to show, unshow, and update magnifier on Apple platforms', (WidgetTester tester) async { |
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.
Super nit: Should this just say "on iOS"?
| @@ -2360,7 +2360,7 @@ void main() { | |||
| break; | |||
| } | |||
| }, | |||
| variant: TargetPlatformVariant.all(), | |||
| variant: TargetPlatformVariant.all(excluding: <TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), | |||
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: Change the title to say "on Apple platforms"?
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.
You're right. This also reminds me that I should add a test for Apple/non-Apple platforms.
This change moves the long press logic from the material layer (TextField) back into the widgets layer (TextSelection). This includes changing the long press behavior to match the platform behavior on CupertinoTextField and TextField. Previously in some cases CupertinoTextField and TextField attempted to match the behavior of the theme rather than the platform, this resulted in CupertinoTextField for Android having iOS text gestures.
This change fixes edge scrolling on long press by using the same technique used during drag to select text. We offset the new selection baseOffset by the editable and scrollable offsets. We also bring the selection into view for all platforms now on a long press or drag.
Fixes #26394
Pre-launch Checklist
///).