[go: nahoru, domu]

Skip to content
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 selection toolbar not showing on drag end #121110

Merged
merged 3 commits into from
Mar 26, 2023

Conversation

jankuss
Copy link
Contributor
@jankuss jankuss commented Feb 20, 2023

Fixes #119314

The regression was caused initially by this commit: f014c1e

Before

Before, ending the drag didn't show the toolbar, making it impossible to copy the text after adjusting the selection handles.

Screen.Recording.2023-02-20.at.23.32.51.mov

After

Now ending the drag will show the toolbar again:

Screen.Recording.2023-02-20.at.23.29.18.mov

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.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Feb 20, 2023
@jankuss jankuss force-pushed the fix-selection-toolbar-not-showing branch 2 times, most recently from 058d8d1 to 5c017ea Compare February 21, 2023 08:22
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.

Thank you for fixing this! We totally missed this when implementing the magnifier.

Just a minor comment about the use of pump in your tests, and you also need to sync with the master branch. Otherwise this should be good to go.

@@ -533,6 +533,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
} else {
_selectionOverlay!.hideMagnifier();
_selectionOverlay!.showToolbar(
context: context,
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch, context should be provided when contextMenuBuilder is provided. Thanks!


await gesture.up();
await tester.pump(const Duration(milliseconds: 500));
await tester.pump(const Duration(milliseconds: 500));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you replace these pumps with pumpAndSettle or, if possible, a pump with no Duration? Ideally we shouldn't have any arbitrary timing things like this unless it's totally necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was able to remove most of the pumps with duration, except for one location. I believe this one is necessary though, because it is also used in other tests.

For example, here:
https://github.com/flutter/flutter/blob/686266e4184a107b5e52ddc871cb5400d8caf9df/packages/flutter/test/material/selection_area_test.dart#L61

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, it's fine like this then 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this particular use of pump is so the down event is held and detected as a long press.

@jankuss jankuss force-pushed the fix-selection-toolbar-not-showing branch from 5c017ea to 686266e Compare March 3, 2023 18:42
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 👍

I re-ran two tests that looked like infrastructure flakes.

packages/flutter/test/material/selection_area_test.dart Outdated Show resolved Hide resolved
@justinmc
Copy link
Contributor
justinmc commented Mar 6, 2023

The test failure is something unrelated that I've seen on another PR as well. Can you push a merge commit?

Or a rerun may do it.

@jankuss jankuss force-pushed the fix-selection-toolbar-not-showing branch from ae81915 to 63b67ba Compare March 23, 2023 18:07
@jankuss
Copy link
Contributor Author
jankuss commented Mar 23, 2023

@Renzo-Olivares @LongCatIsLooong could you take a look?

Copy link
Contributor
@Renzo-Olivares Renzo-Olivares left a comment

Choose a reason for hiding this comment

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

LGTM

@mzdm
Copy link
Contributor
mzdm commented Apr 1, 2023

Would be good cherry pick candidate IMO

@justinmc
Copy link
Contributor
justinmc commented Apr 5, 2023

A new stable release will be cut soon with this fix in it, so I think that will work out and we won't need to cherry pick.

Well CC @itsjustkevin in case. I guess it won't be released for awhile.

@mingxin-yang
Copy link

Hello, which flutter version fixes this function?

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
@justinmc
Copy link
Contributor

Looks like this was tagged in 3.9.0-18.0.pre.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

[SelectionArea] Selecting text and then resizing the selection dismisses the contextMenu
6 participants