Skip to content

Fix pointer scroll for nested NeverScrollables#70953

Merged
fluttergithubbot merged 5 commits intoflutter:masterfrom
Piinks:fixPointerScroll
Nov 21, 2020
Merged

Fix pointer scroll for nested NeverScrollables#70953
fluttergithubbot merged 5 commits intoflutter:masterfrom
Piinks:fixPointerScroll

Conversation

@Piinks
Copy link
Contributor

@Piinks Piinks commented Nov 20, 2020

Description

This fixes a regression introduced in #66039
While initiating a pointerScroll for a Scrollable with the computed delta is correct, determining the scrollable that receives the pointer scroll event should still go through the targetScrollOffset evaluation first, otherwise in the case of the nested NeverScrollable, the event is claimed by the wrong scroll view.

Related Issues

Fixes #70948

Tests

PointerScroll on nested NeverScrollable ListView goes to outer Scrollable.

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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.

@Piinks Piinks added c: regression It was better in the past than it is now framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. platform-web Web applications specifically a: desktop Running on desktop labels Nov 20, 2020
@google-cla google-cla bot added the cla: yes label Nov 20, 2020
@YeungKC
Copy link
Member

YeungKC commented Nov 20, 2020

When I saw the code I understood completely. It was an oversight on my part.

@YeungKC
Copy link
Member

YeungKC commented Nov 20, 2020

LGTM~

final double targetScrollOffset = _targetScrollOffsetForPointerScroll(event);
// Only express interest in the event if it would actually result in a scroll.
if (targetScrollOffset != 0) {
if (targetScrollOffset != position.pixels) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we be checking _physics != null && !_physics!.shouldAcceptUserOffset(position)) before calling pointerSignalResolver.register?

Copy link
Member

Choose a reason for hiding this comment

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

I think that's right now because #37211

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was part of another change, but I moved it to precede pointerSignalResolver.register and all the tests passed. Makes sense to me!

Copy link
Member

@YeungKC YeungKC Nov 21, 2020

Choose a reason for hiding this comment

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

              Stack(
                children: [
                  Positioned.fill(
                    child: someList(),
                  ),
                  someList(
                      physics: NeverScrollableScrollPhysics,
                  ),
                ],
              );

If my pointer signal scrolls on the second list, should the expected behavior be to scroll nothing at all?

If you moved, then the first list is scrolled.

I believe this is a bit counterintuitive?

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 actually a common design pattern I've seen before. In the repro provided in the bug, it creates two parallel scroll views that scroll as one. Another similar use case was reported in #70902

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

LGTM

@hamirshekhawat
Copy link

Is this PR related to https://stackoverflow.com/questions/67706136/nested-listviews-scrolling-behavior-different-when-scrolled-using-drag-vs-scroll? I'd really like to know as the solution I have is to use Listener and MouseRegion combination to control scrollbehavior but my nested list rebuild is expensive.

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

Labels

a: desktop Running on desktop c: regression It was better in the past than it is now f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. platform-web Web applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pointer scroll not handled correctly for nested NeverScrollable ScrollView

5 participants