-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Text selection located wrong position when selecting multiple lines over max lines #102747
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
|
cc @chunhtai |
chunhtai
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.
logic looks good, left some comments
|
thanks for quick review. |
chunhtai
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
|
@justinmc |
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.
Thanks for fixing this! FYI It looks like there is a legitimate test failure in text_selection_test.dart.
Also, about your screenshots in #102747 (comment). I'm not convinced that the new menu location is correct. Shouldn't it be below? On native Android I see the selection color expand for the full width of the input, which Flutter might also be getting wrong unrelated to this PR, and the toolbar goes below.
| delegate: TextSelectionToolbarLayoutDelegate( | ||
| anchorAbove: anchorAbove - localAdjustment - contentPaddingAdjustment, | ||
| anchorBelow: anchorBelow - localAdjustment + contentPaddingAdjustment, | ||
| fitsAbove: fitsAbove, |
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.
Previously I wasn't passing this because TextSelectionToolbarLayoutDelegate could calculate it itself (see the docs), but I suppose we can pass it in here to avoid calculating it twice.
|
@justinmc I can pass all tests on local, but it doesn't pass on github actions. can you take a look? |
|
hi @justinmc I'm not sure why |
|
@justinmc |
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 👍
Thanks for fixing this. I tried running your branch with the sample in the issue and it worked correctly for me. Glad to see you got the tests passing.
| ); | ||
|
|
||
| testWidgets( | ||
| 'When select multiple lines over max lines', |
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: "select" => "selecting" Here and in the other test.
| expect(find.text('Select All'), findsNothing); | ||
| expect(find.text('◀'), findsNothing); | ||
| expect(find.text('▶'), findsNothing); | ||
|
|
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 add a comment like this? "The menu appears at the top of the visible selection."
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.
And same for the other test below.
| final Offset cutOffset = tester.getTopLeft(find.text('Cut')); | ||
| final Offset textFieldOffset = | ||
| tester.getTopLeft(find.byType(CupertinoTextField)); | ||
| expect(cutOffset.dy + 36, equals(textFieldOffset.dy)); |
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: Is there any way to explain where this 36 number comes from?
| final Offset cutOffset = tester.getTopLeft(find.text('Cut')); | ||
| final Offset textFieldOffset = | ||
| tester.getTopLeft(find.byType(TextField)); | ||
| expect(cutOffset.dy + 25, equals(textFieldOffset.dy)); |
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.
Same question about explaining this 25 value.
|
@justinmc |
|
This is good to go. I'm writing myself a note to merge this on Monday. |
|
@justinmc btw, you mentioned it before
this issue has already been reported? I wanna contribute it next if I can. |
|
@takassh No I have not seen an issue for the width of the selection highlight. That's great if you want to work on it! Could you create one and mention me? |
… lines over max lines (flutter/flutter#102747)
… lines over max lines (flutter/flutter#102747)
… lines over max lines (flutter/flutter#102747)
…ver max lines (flutter#102747) Fix for text selection toolbar position in cases with overflowing text.
… lines over max lines (flutter/flutter#102747)
… lines over max lines (flutter/flutter#102747)


Fixes #96453
This PR fixes bugs that text selection located wrong position when selecting multiple lines over max lines.
related closed pr #96471
Pre-launch Checklist
///).