Skip to content

Avoid flickering while dragging to select text#29563

Merged
mdebbar merged 1 commit intoflutter:masterfrom
mdebbar:text_selection_flickering
Mar 21, 2019
Merged

Avoid flickering while dragging to select text#29563
mdebbar merged 1 commit intoflutter:masterfrom
mdebbar:text_selection_flickering

Conversation

@mdebbar
Copy link
Contributor

@mdebbar mdebbar commented Mar 18, 2019

When dragging to select text, we continuously call onSelectionChanged which causes the selection box and handles to be repainted. This causes unnecessary flickering to happen.

The solution in this PR is to avoid calling onSelectionChanged if the new selection is the same as the existing one.

Another unrelated change is the addition of tests addressing @xster comment in #29395. As part of that, I found out that the existing drag handles ... test was not expecting the right thing.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

@mdebbar mdebbar requested review from Hixie, jslavitz, xster and yjbanov March 18, 2019 19:38
@goderbauer goderbauer added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Mar 18, 2019
@xster
Copy link
Member

xster commented Mar 19, 2019

The CI are all flakes. Restarted

Copy link
Member

Choose a reason for hiding this comment

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

tott/510.md

Don't do redirections, just put numbers in, e.g. base 4, extent 9 directly.

Copy link
Member

Choose a reason for hiding this comment

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

😮

use numbers directly here too

Copy link
Member

Choose a reason for hiding this comment

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

Add this test in cupertino/text_field_test.dart too

Copy link
Member

Choose a reason for hiding this comment

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

Add this test to material and cupertino text_field_test too via gestures (in case we move those widgets to use something else than selectPositionAt in the future).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the test to material for now. Cupertino still doesn't have text selection via mouse but I'll have a PR for that tomorrow.

Copy link
Member

Choose a reason for hiding this comment

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

Is this a mouse specific issue or would this not happen with a handle drag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xster yes, for some reason dragging the handles doesn't flicker at all.

That said, your comment made me think about other scenarios that may cause flickering, and I found one :) Long-press-drag has the same issue in the material text field. But it's not fixed by this PR. Filed an issue here to be fixed separately: #29682.

@xster
Copy link
Member

xster commented Mar 20, 2019

LGTM. Thanks!

@mdebbar mdebbar force-pushed the text_selection_flickering branch from b1e9d96 to b5d5fa6 Compare March 20, 2019 19:52
@mdebbar mdebbar merged commit c80366a into flutter:master Mar 21, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

4 participants