-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Make VirtualizingStackPanel better handle container size changes #16168
Conversation
If any container U size has changed since the last layout pass then `StartU` must be considered unstable as the average container height will have changed.
If the focused element has been moved outside the visible viewport due to a realized container size change, then we need to ensure it's positioned correctly.
You can test this PR using the following package version. |
Marking this as a draft because I've discovered that it's not working quite as intended. |
Marked this PR as ready for review again. It isn't perfect but it's better than before and a better fix will be more involved. The problems are twofold:
|
And revert the expected results for another test to the way they were at the beginning of this PR.
Use the desired size of _measured_ containers instead of the bounds: a layout pass may not had completed on the containers yet, so the bounds may not be up-to-date. Was easier to move the estimation methods out of `RealizedStackElements` and into `VirtualizingStackPanel` itself in order to do this, and arguably makes more sense.
Thanks for testing @Whiletru3 - I've updated the PR to address some of the concerns I had with the original naïve approach and hopefully this should have fixed the issue you were seeing. |
You can test this PR using the following package version. |
Hello @grokys , Using your last changes, I can't reproduce the issue :) Now, I just have to tackle the issue of keeping the offset when zoom in or out. |
@Whiletru3 this PR will go into 11.1.1. But it might be backported to the 11.0.x, I will lable it for the consideration. |
) * Add a failing test for #15712. * Validate StartU at the start of a measure pass. If any container U size has changed since the last layout pass then `StartU` must be considered unstable as the average container height will have changed. * Correctly position focused element. If the focused element has been moved outside the visible viewport due to a realized container size change, then we need to ensure it's positioned correctly. * We can skip check if StartU is already unstable. * Don't invalidate virt. panels more than necessary. * Add another virt panel test. And revert the expected results for another test to the way they were at the beginning of this PR. * Tweak container size estimation. Use the desired size of _measured_ containers instead of the bounds: a layout pass may not had completed on the containers yet, so the bounds may not be up-to-date. Was easier to move the estimation methods out of `RealizedStackElements` and into `VirtualizingStackPanel` itself in order to do this, and arguably makes more sense.
) * Add a failing test for #15712. * Validate StartU at the start of a measure pass. If any container U size has changed since the last layout pass then `StartU` must be considered unstable as the average container height will have changed. * Correctly position focused element. If the focused element has been moved outside the visible viewport due to a realized container size change, then we need to ensure it's positioned correctly. * We can skip check if StartU is already unstable. * Don't invalidate virt. panels more than necessary. * Add another virt panel test. And revert the expected results for another test to the way they were at the beginning of this PR. * Tweak container size estimation. Use the desired size of _measured_ containers instead of the bounds: a layout pass may not had completed on the containers yet, so the bounds may not be up-to-date. Was easier to move the estimation methods out of `RealizedStackElements` and into `VirtualizingStackPanel` itself in order to do this, and arguably makes more sense.
What does the pull request do?
As described in #15712, if a container changes size after layout then glitches occur when scrolling.
To fix this:
StartU
is no longer valid because the average element size will have changed, so mark is as unstableRealizedStackElements
and intoVirtualizingStackPanel
itself in order to do this, and arguably makes more senseFixed issues
Fixes #15712