Text selection located wrong position when selecting multiple lines over max lines#102747
Text selection located wrong position when selecting multiple lines over max lines#102747justinmc merged 10 commits intoflutter:masterfrom takassh:text_selection
Conversation
|
cc @chunhtai |
chunhtai
left a comment
There was a problem hiding this comment.
logic looks good, left some comments
|
thanks for quick review. |
|
@justinmc |
justinmc
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
Nit: Maybe add a comment like this? "The menu appears at the top of the visible selection."
There was a problem hiding this comment.
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.
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.
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
///).