-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Let scrollOffsetCorrection on small lists not leave the list stuck in overscroll #17599
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
Conversation
@@ -252,11 +252,13 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { | |||
/// see the discussion there for why that might still be a bad idea.) | |||
void correctPixels(double value) { | |||
_pixels = value; | |||
_didChangeViewportDimensionOrPixels = true; |
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.
The documentation says "In particular, this is typically called as a response to applyViewportDimension or applyContentDimensions", but here you're writing code that assumes it's called before applyContentDimensions, which seems dubious.
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.
Ya, I'm a bit concerned touching something this central since there's a lot of implicit coupling, though all the tests passed.
I wasn't too sure what's the best way either. The correct behaviour seems to work with long lists because applyNewDimensions
is called on line 426 to re-kick the start ballistic activity. Perhaps you have a better solution.
This field seemed like the least invasive as far as I can tell since the current code which uses the field instead of the setter seems to want to defer signaling after this loop here https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/rendering/viewport.dart#L1053. I'm assuming the documentation saying it's used in response to applyContentDimensions likely meant applyContentDimensions resets this value to false after consuming it.
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.
PTAL, did what we talked about offline and added some docs and an assert.
@@ -84,11 +84,6 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc | |||
return super.setPixels(newPixels); | |||
} | |||
|
|||
@override | |||
void correctBy(double correction) { |
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.
I left the correctPixels in the super alone like we talked about but this is an actual bug since it circumvents its super.correctBy and doesn't actually do anything different.
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.
cool
/// | ||
/// See also: | ||
/// | ||
/// * The method [correctBy], which is a method of [ViewportOffset] be used |
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.
-be
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.
done
/// See also: | ||
/// | ||
/// * The method [correctBy], which is a method of [ViewportOffset] be used | ||
/// by viewport render objects to also correct the offset during layout |
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.
-also
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.
done
/// See also: | ||
/// | ||
/// * [jumpTo], for also changing the scroll position but applying the | ||
/// change immediately and notifying its listeners. |
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.
mention that jumpTo is for when you're not in layout.
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.
done
/// | ||
/// See also: | ||
/// | ||
/// * [correctBy], a more specialized way of changing the current offset |
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.
-more specialized (otherwise it makes it sound like jumpTo
is also for use during layout)
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.
done
void correctPixels(double value) { | ||
_pixels = value; | ||
} | ||
|
||
// See also [correctPixels] which is used by the [ScrollPosition] itself to | ||
// set the offset initially during construction or after | ||
// [applyViewportDimension] or [applyContentDimensions] is called. |
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.
///?
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.
Ah, I didn't realize dartdoc'ing overrides actually works. Done
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.
oh we should also include the docs from the superclass, i didn't realize it was doing that. (These docs will replace the superclass docs.)
void correctPixels(double value) { | ||
_pixels = value; | ||
} | ||
|
||
// See also [correctPixels] which is used by the [ScrollPosition] itself to |
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.
comma before "which"
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.
done
Fixes #17474
The issue is if offset corrections don't cause the viewport content's scroll extent to change, lists in overscroll can be stuck.