-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Fixed render overflow error and implemented native solution of text s… #39624
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
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 doing this! I think this is a step in the direction of a really nice solution that looks native, but I've pointed out a few issues we should work through. This is more complicated that it looks on the surface. Let me know if I can help point you in the right direction for any of this.
The failures seem to be caused by this test:
| 'long press selects word and shows toolbar (Android)', |
It's expecting to find 4 FlatButtons in the selection toolbar, but it only finds 3 since this PR hides any buttons beyond 3. The ideal solution here is definitely to move buttons to the submenu only when they physically exceed the width of the screen. I have some ideas about this in the comments below.
Also, on native Android, there is an animation between the menu open/closed states that we should include as well if possible:
| return Container(width: 0.0, height: 0.0); | ||
| } | ||
|
|
||
| if (items.length <= 3) { |
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 ideal solution is to adjust the number of items visible such that the maximum number fit on the screen without overflowing. Hardcoding it to 3 is a breaking change because the many tests that depend on 4 buttons being on the screen will break. It also may still overflow in languages with very long strings in the first 3 buttons.
Codecov Report
@@ Coverage Diff @@
## master #39624 +/- ##
=========================================
Coverage ? 60.61%
=========================================
Files ? 194
Lines ? 18849
Branches ? 0
=========================================
Hits ? 11426
Misses ? 7423
Partials ? 0
Continue to review full report at Codecov.
|
|
Thank you sir for replying. I will surely make these changes! |
|
Thanks for following up @imlegend19! Let me know if I can help clarify anything! |
|
@justinmc can you help me in solving this merge conflict? |
|
I tried to do this myself, but I think I can't commit to your PR. So here's what you should do to fix the conflict. It seems like there are two conflicts, both in material/text_selection.dart. For the first conflict, final MaterialLocalizations localizations = MaterialLocalizations.of(context);
final List<Widget> items = <Widget>[
if (widget.handleCut != null) FlatButton(child: Text(localizations.cutButtonLabel), onPressed: widget.handleCut),
if (widget.handleCopy != null) FlatButton(child: Text(localizations.copyButtonLabel), onPressed: widget.handleCopy),
if (widget.handlePaste != null) FlatButton(child: Text(localizations.pasteButtonLabel), onPressed: widget.handlePaste),
if (widget.handleSelectAll != null) FlatButton(child: Text(localizations.selectAllButtonLabel), onPressed: widget.handleSelectAll),
];For the second conflict you should just accept the changes. It seems like your change was just formatting. return delegate.selectAllEnabled &&
value.text.isNotEmpty &&
!(value.selection.start == 0 && value.selection.end == value.text.length); |
|
@justinmc I have made the changes what you requested, still the tests fail! |
|
Here's what the failure is: Looks like it is probably a legitimate failure. You should be able to run material/text_field_test.dart and debug the failure locally. |
imlegend19
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.
I have made your changes but it still does not solve the issue.
Here is the stacktrace: |
# Conflicts: # packages/flutter/lib/src/material/text_selection.dart
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. ℹ️ Googlers: Go here for more info. |
|
Hi @imlegend19, |
|
CLAs look good, thanks! ℹ️ Googlers: Go here for more info. |
Thank you @Piinks for your help. |
|
It looks like that failure is due to breaking a goldens test, which is to be expected for this PR. Goldens tests are visual diff tests, so because the selection menu looks different in this PR, it will break any visual diff test that covers the selection menu. See the image from your stack trace, which does include the selection menu: https://github.com/flutter/goldens/blob/master/packages/flutter/test/material/text_field_opacity_test.0.4.png I added the "breaking change" tag, and we'll need to follow the instructions for breaking changes when we're ready. We'll also need to update the golden tests when we're sure that this looks exactly how we want it to. |
|
How should we proceed in modifying the golden tests? |
|
I can help with the golden file updates when this is ready to land. :) |
|
@imlegend19 Are you still available for working on this PR? I might need to take over this work soon since this is a major bug for people. |
|
I've started investigating my own solution in #49391. I'll close this PR if I am able to merge that one. |
|
Hi, I am working on this PR but still stuck in the same error! |
|
any updates? |
Hi @imlegend19 can you update your branch? It looks like this PR has aged a bit and now has merge conflicts with the master branch. |
|
@imlegend19 I'm getting close to finishing my solution in #49391. It will make this PR redundant, unfortunately. Sorry about the overlapping work. I recommend we close this PR if you're alright with that. If you still want to help out on this problem, we still need to do a similar solution for iOS, and no one has started that yet that I know of. |
|
I'm closing this in favor of #49391. If anyone sees any problems that that PR doesn't cover, please let me know! |

Description
Implemented the native Android solution for text selection.
Related Issues
Fixes #35826
Tests
I added the following tests:
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?