Skip to content

fix: make sure virtualizer clears item placeholder height - #4793

Merged
web-padawan merged 3 commits into
masterfrom
fix/virtualizer-resize-observer-not-invoking
Oct 21, 2022
Merged

web-padawan merged 3 commits into
masterfrom
fix/virtualizer-resize-observer-not-invoking

Conversation

@tomivirkki

@tomivirkki tomivirkki commented Oct 21, 2022 •

Copy link
Copy Markdown
Member

Fixes vaadin/flow-components#3900

The issue was caused by the following sequence:

  1. The first time the list renders, everything looks good
  2. When the items get refreshed, virtual-list requests an update from virtualizer
  3. Virtualizer runs the given updateElement callback function
  4. This causes the <flow-component-renderer> to replace its content and the item becomes temporarily empty / to have zero height
  5. The __updateElement function notices the item height is 0 and it adds placeholder padding to it. It expects the temporary padding to get cleared once the item regains size, which would cause the resize observer to fire
  6. Before the virtualizer's resize observer ever gets to react to the size change, the flow-component-renderer is populated with new content, which makes the item's height again match the original value.
  7. Since the item's content-box height is the same as it was initially, from the resize observer's point of view, item resize never took place, so it doesn't fire
  8. The placeholder padding remains on the item!

Fix attempt 1:
To fix this issue, let's make the virtualizer's resize observer use box: 'border-box' so that a change in the item's padding will also make the observer invoke.

EDIT: Looks like this approach breaks some other tests. Will need to find a better one.

Fix attempt 2:
To fix this issue, let's make the virtualizer manually schedule a resize handler call after it applies the placeholder padding to make sure it gets cleared in this scenario.

@sonarqubecloud

Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@web-padawan web-padawan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Visual test failures are unrelated, I will investigate them separately.

@web-padawan
web-padawan merged commit 65569bf into master Oct 21, 2022
@web-padawan
web-padawan deleted the fix/virtualizer-resize-observer-not-invoking branch October 21, 2022 17:11
web-padawan pushed a commit that referenced this pull request Oct 21, 2022
)

Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
web-padawan pushed a commit that referenced this pull request Oct 21, 2022
)

Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
web-padawan pushed a commit that referenced this pull request Oct 23, 2022
)

Co-authored-by: Tomi Virkki <tomivirkki@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Virtual List adds padding to LitTemplate items

3 participants