Skip to content

Fix selection area causes small scrollables to bounce#112816

Merged
auto-submit[bot] merged 2 commits intoflutter:masterfrom
chunhtai:issues/110917
Oct 10, 2022
Merged

Fix selection area causes small scrollables to bounce#112816
auto-submit[bot] merged 2 commits intoflutter:masterfrom
chunhtai:issues/110917

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Oct 3, 2022

The problem is that the Selection container of scrollable may pass rect larger than the scrollable to the auto scroller. The auto scroll attempt to scroll the scrollable to review the target rect, and it keep scrolling up and down to try to fit the target rect.

This pr fixes it by passing zero size rect to autoscroller instead.

fixes #110917

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.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. labels Oct 3, 2022
@chunhtai chunhtai requested a review from justinmc October 3, 2022 19:34
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is mainly a refactor, the only change is it used to use math.max to calculate overDrag which is incorrect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This causes problem when the scrollable is less than 200

@chunhtai
Copy link
Contributor Author

chunhtai commented Oct 6, 2022

@justinmc a friendly bump

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 👍 with nits.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, this must have been a typo before when math.max was being used here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why the extra 20 pixels here?

Copy link
Contributor

Choose a reason for hiding this comment

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

And below as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before you can start auto drag if the drag closer to the boundary(with in 100 pixels), it now need to drag pass the rect. Added comments to the tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: "Should not stuck" => "Shouldn't be stuck"

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use takeException here instead of the try/catch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scroll crazy when SelectionArea + SingleChildScrollView

2 participants