Skip to content

Conversation

@takassh
Copy link
Contributor

@takassh takassh commented Apr 28, 2022

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

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

Screen Shot 2022-04-28 at 3 35 07 PM

@flutter-dashboard flutter-dashboard bot added 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. labels Apr 28, 2022
@takassh
Copy link
Contributor Author

takassh commented Apr 28, 2022

hi
test is failed because of When renders below a block of text, menu appears below bottom endpoint.
I want to confirm whether it is expected behavior.

master pr
Screenshot_1651150321 Screenshot_1651150712

@takassh
Copy link
Contributor Author

takassh commented May 10, 2022

cc @chunhtai

Copy link
Contributor

@chunhtai chunhtai left a 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

@takassh
Copy link
Contributor Author

takassh commented May 11, 2022

thanks for quick review.
I fixed them and added a new test for CupertinoTextField.
@chunhtai

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chunhtai chunhtai requested a review from justinmc May 11, 2022 16:25
@takassh
Copy link
Contributor Author

takassh commented May 17, 2022

@justinmc
Hi, what should I do next?

Copy link
Contributor

@justinmc justinmc left a 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,
Copy link
Contributor

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.

@takassh
Copy link
Contributor Author

takassh commented May 19, 2022

@justinmc
ok, then I put anchorBelow back.

I can pass all tests on local, but it doesn't pass on github actions. can you take a look?

@takassh
Copy link
Contributor Author

takassh commented May 27, 2022

hi @justinmc

I'm not sure why Linux web_long_running_tests_1_5 failed.
please tell me what to do?
(sorry for bothering you)

@takassh
Copy link
Contributor Author

takassh commented May 31, 2022

@justinmc
finally, I could pass all tests.
please review it.

Copy link
Contributor

@justinmc justinmc left a 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',
Copy link
Contributor

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);

Copy link
Contributor

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."

Copy link
Contributor

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));
Copy link
Contributor

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));
Copy link
Contributor

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.

@takassh
Copy link
Contributor Author

takassh commented Jun 2, 2022

@justinmc
thanks for review
added comments

@justinmc
Copy link
Contributor

justinmc commented Jun 4, 2022

This is good to go. I'm writing myself a note to merge this on Monday.

@takassh
Copy link
Contributor Author

takassh commented Jun 4, 2022

@justinmc
thank you!

btw, you mentioned it before

the selection color expand for the full width of the input, which Flutter might also be getting wrong unrelated to this PR

#102747 (review)

this issue has already been reported? I wanna contribute it next if I can.

@justinmc justinmc merged commit 4b4c876 into flutter:master Jun 7, 2022
@justinmc
Copy link
Contributor

justinmc commented Jun 7, 2022

@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?

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jun 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Jun 8, 2022
camsim99 pushed a commit to camsim99/flutter that referenced this pull request Aug 10, 2022
…ver max lines (flutter#102747)

Fix for text selection toolbar position in cases with overflowing text.
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 30, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/plugins that referenced this pull request Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

Successfully merging this pull request may close these issues.

Text selection toolbar offset bound to global position of the text

3 participants