-
Notifications
You must be signed in to change notification settings - Fork 29.7k
fix: Inconsistency of SelectionArea when scrolling #128765
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: Inconsistency of SelectionArea when scrolling #128765
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Hi @paurakhsharma, thank you for your contribution! Can you explain how this pull request fixes the issue listed, i'm not sure I understand. A test verifying the fix will also be needed to go forward with this change. |
|
As mentioned by @gnprice in #120892 (comment) I have updated the test to make sure |
e596f25 to
897f831
Compare
| }); | ||
|
|
||
| testWidgets( | ||
| "touch long press cancel doesn't send ClearSelectionEvent", |
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: doesn't -> does not.
| addTearDown(gesture.removePointer); | ||
|
|
||
| await tester.pump(const Duration(milliseconds: 500)); | ||
| await gesture.cancel(); |
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.
This seems like a reasonable way of testing the cancel. I think we should also test the specific situation of the cancel in a scrollable as a regression test. Something like long press to select a word in a scrollable. Then try scrolling. The selection should be retained after the scroll.
Also add a regression test comment at the top of the test. Something like
// Regression test for https://github.com/flutter/flutter/issues/128765
|
@chunhtai if you had any thoughts regarding this change. |
Renzo-Olivares
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 all the changes! I had a few nits but overall the new test looks good.
| 'touch long press cancel does not send ClearSelectionEvent', | ||
| (WidgetTester tester) async { | ||
| final UniqueKey spy = UniqueKey(); | ||
| await tester.pumpWidget(MaterialApp( |
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 formatting: move MaterialApp to its own line.
| selectionControls: materialTextSelectionControls, | ||
| child: SelectionSpy(key: spy), | ||
| ), | ||
| )); |
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 formatting: move trailing parentheses to their own line and separate with a comma.
| await tester.startGesture(const Offset(200.0, 200.0)); | ||
| addTearDown(selectGesture.removePointer); | ||
| await tester.pump(const Duration(milliseconds: 500)); | ||
|
|
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.
Maybe here instead of moving immediately after the long press we should just do selectGesture.up() and check for the SelectWordSelectionEvent. Then clear the events list with renderSelectionSpy.events.clear(). Then try a scroll gesture to see that ClearSelectionEvent is not sent. This would simulate taking our finger off the screen and then initiating a scroll.
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.
Thank you @Renzo-Olivares I have updated the PR accordingly.
Renzo-Olivares
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 with one small nit. Thanks for the contribution!
| child: SelectionSpy(key: spy), | ||
| ), | ||
| ), | ||
| ); |
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 formatting: line this up with await.
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.
Thank you, Done!
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
Roll Flutter from 042c036 to 96a2c05 (60 revisions) flutter/flutter@042c036...96a2c05 2023-06-26 49699333+dependabot[bot]@users.noreply.github.com Bump ossf/scorecard-action from 2.1.3 to 2.2.0 (flutter/flutter#129453) 2023-06-26 [email protected] Roll Flutter Engine from 63582320d20e to 4032a9bc964e (2 revisions) (flutter/flutter#129569) 2023-06-26 [email protected] Updated TextMagnifierExampleApp to M3 (flutter/flutter#129381) 2023-06-26 [email protected] Roll Flutter Engine from debee7cece49 to 63582320d20e (3 revisions) (flutter/flutter#129563) 2023-06-26 [email protected] Fix `AnimatedList` & `AnimatedGrid` doesn't apply `MediaQuery` padding (flutter/flutter#129556) 2023-06-26 [email protected] Process only specific labels. (flutter/flutter#129475) 2023-06-26 [email protected] Roll Packages from d041934 to 6b70804 (7 revisions) (flutter/flutter#129559) 2023-06-26 [email protected] Make bug templates more consistent (flutter/flutter#129460) 2023-06-26 [email protected] Roll Flutter Engine from be46101e952d to debee7cece49 (1 revision) (flutter/flutter#129544) 2023-06-26 [email protected] Roll Flutter Engine from 88ff46e1efc1 to be46101e952d (2 revisions) (flutter/flutter#129540) 2023-06-26 [email protected] Roll Flutter Engine from 317673b3278a to 88ff46e1efc1 (1 revision) (flutter/flutter#129534) 2023-06-26 [email protected] Roll Flutter Engine from 593e1d9a9cf5 to 317673b3278a (3 revisions) (flutter/flutter#129531) 2023-06-25 [email protected] Roll Flutter Engine from 5178e8ab7764 to 593e1d9a9cf5 (1 revision) (flutter/flutter#129514) 2023-06-25 [email protected] Roll Flutter Engine from 100f6fc854b4 to 5178e8ab7764 (1 revision) (flutter/flutter#129508) 2023-06-25 [email protected] Roll Flutter Engine from a9f446e25f0c to 100f6fc854b4 (1 revision) (flutter/flutter#129498) 2023-06-25 [email protected] Roll Flutter Engine from 5b1b98305768 to a9f446e25f0c (1 revision) (flutter/flutter#129495) 2023-06-24 [email protected] Roll Flutter Engine from 72c902ce3b81 to 5b1b98305768 (2 revisions) (flutter/flutter#129493) 2023-06-24 [email protected] Roll Flutter Engine from f2976add9414 to 72c902ce3b81 (1 revision) (flutter/flutter#129489) 2023-06-24 [email protected] Roll Flutter Engine from 76a5e971dc09 to f2976add9414 (1 revision) (flutter/flutter#129487) 2023-06-24 [email protected] Roll Flutter Engine from 79fd6beea087 to 76a5e971dc09 (1 revision) (flutter/flutter#129483) 2023-06-24 [email protected] Roll Flutter Engine from 30ac9107f2f9 to 79fd6beea087 (1 revision) (flutter/flutter#129479) 2023-06-24 [email protected] Roll Flutter Engine from ee65380bf3fd to 30ac9107f2f9 (1 revision) (flutter/flutter#129476) 2023-06-24 [email protected] Roll Flutter Engine from 240a86f40781 to ee65380bf3fd (2 revisions) (flutter/flutter#129474) 2023-06-24 [email protected] Fix issues with no response bot. (flutter/flutter#129470) 2023-06-24 [email protected] Roll Flutter Engine from 5e6dcf959ea0 to 240a86f40781 (1 revision) (flutter/flutter#129473) 2023-06-24 [email protected] Roll Flutter Engine from 550bfedc8760 to 5e6dcf959ea0 (1 revision) (flutter/flutter#129468) 2023-06-24 [email protected] Roll Flutter Engine from c1abd1f17ab1 to 550bfedc8760 (3 revisions) (flutter/flutter#129466) 2023-06-24 [email protected] [devicelab] Add platform view scroll benchmarks for Impeller on Android (flutter/flutter#129455) 2023-06-23 [email protected] Roll Flutter Engine from eca910dd5e3f to c1abd1f17ab1 (3 revisions) (flutter/flutter#129456) 2023-06-23 [email protected] Roll Flutter Engine from f8a39cb4dc56 to eca910dd5e3f (3 revisions) (flutter/flutter#129451) 2023-06-23 [email protected] Roll Flutter Engine from 74ef61859bdc to f8a39cb4dc56 (2 revisions) (flutter/flutter#129445) 2023-06-23 [email protected] Add CallbackShortcuts widget of the week video (flutter/flutter#129296) 2023-06-23 [email protected] Roll Flutter Engine from 060cd9c17df3 to 74ef61859bdc (3 revisions) (flutter/flutter#129444) 2023-06-23 [email protected] Roll Flutter Engine from cd30a48ef889 to 060cd9c17df3 (3 revisions) (flutter/flutter#129440) 2023-06-23 [email protected] Roll Flutter Engine from 27f3498286ff to cd30a48ef889 (4 revisions) (flutter/flutter#129437) 2023-06-23 [email protected] Add a devicelab test to recipes cq. (flutter/flutter#129411) 2023-06-23 [email protected] fix: Inconsistency of SelectionArea when scrolling (flutter/flutter#128765) 2023-06-23 [email protected] Run misc test shard when examples/api/** change (flutter/flutter#129433) 2023-06-23 49699333+dependabot[bot]@users.noreply.github.com Bump ubuntu from `b795f8e` to `db8bf6f` in /dev/ci/docker_linux (flutter/flutter#128740) 2023-06-23 [email protected] Add r: timeout label to bugs/pr closed by no response bot. (flutter/flutter#129408) 2023-06-23 [email protected] Remove .github/move.yml. (flutter/flutter#129409) 2023-06-23 [email protected] Roll Packages from 95bc1c6 to d041934 (6 revisions) (flutter/flutter#129429) 2023-06-23 [email protected] Roll Flutter Engine from aca26b2afc27 to 27f3498286ff (16 revisions) (flutter/flutter#129421) 2023-06-23 [email protected] Add comments to .ci.yaml that were removed from recipes. (flutter/flutter#129321) 2023-06-23 [email protected] Update no response to use core action. (flutter/flutter#129405) 2023-06-23 [email protected] Revert "[web] Migrate framework to fully use package:web" (flutter/flutter#129400) ...
This PR fixes inconsistency of SelectionArea when scrolling by removing the
_clearSelectiononlongPressUpdategesture. This in turn makes the selection UX much better.List which issues are fixed by this PR. You must list at least one issue.
Fixes: #120892
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.