Skip to content
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

Listbox virtualized with zoom in/out (using LayoutTransformControl) issues #15712

Closed
Whiletru3 opened this issue May 13, 2024 · 2 comments · Fixed by #16168
Closed

Listbox virtualized with zoom in/out (using LayoutTransformControl) issues #15712

Whiletru3 opened this issue May 13, 2024 · 2 comments · Fixed by #16168
Labels

Comments

@Whiletru3
Copy link
Contributor

Describe the bug

If we use a ListBox with a LayoutTransformControl in the ListBoxItem to be able to zoom in/out, there are some issues :

  1. If I slide to an item, then zoom out and scroll to the first item, there are a space left before the first item :
    EmptySpaceUpAfterDezoom

  2. If I zoom out, select an item, then zoom in (until the selected item goes out of the viewport), the selected item will be still displayed with the old position
    SelectedItemFocusedMoveAtZoom

  3. at launch, there are one ListBoxItem realized, if I zoom out, of course more items will be realized. But if I zoom in again, the max number of ListBoxItem will remain (of course they will be empty). It should be better to flush those item.
    TooMuchListboxItemInTheRecyclerWhenDezoomZoom

To Reproduce

Here is the sample to reproduce :
https://github.com/Whiletru3/Avalonia/tree/VirtualizationImagesSample/samples/VirtualizationImages

Expected behavior

The ListBox should react normally using a LayoutTransformControl

Avalonia version

11.0.10, 11.1

OS

Windows, macOS

Additional context

No response

@Whiletru3 Whiletru3 added the bug label May 13, 2024
@Whiletru3
Copy link
Contributor Author

Do you have any clue (to make a PR) for the resolution of this bug ?

@grokys
Copy link
Member

grokys commented Jun 29, 2024

I've opened a PR with a fix for the first 2 items in this issue: #16168

Regarding item 3: this is intentional - unrealized elements are not removed unless the number of items changes such that the number of realized and unrealized elements is greater than the item count. This is because when scrolling through items with variable heights, the number of required elements changes frequently and so they may be required later.

maxkatz6 pushed a commit that referenced this issue Jul 8, 2024
)

* 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.
grokys added a commit that referenced this issue Jul 24, 2024
)

* 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.
grokys added a commit that referenced this issue Aug 2, 2024
)

* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants