lit / lit/lit

[labs/virtualizer] Scrolling to a far away element using scrollIntoView then nothing gets rendered

Open
#4,767 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
21.8k
Forks
1.1k
Avg merge
18h 25m
Merged PRs (30d)
2

Description

Which package(s) are affected?

Virtualizer (@lit-labs/virtualizer)

Description

When scrolling to a far away element, for example using virtualizer.element(xyz).scrollIntoView then nothing gets rendered,

For example 30000 elements in the list and each element have height 37px. Scrolling to anything above 14984 not working.

(temp2 is the virtualizer ref in the browser console )
temp2.element(14984).scrollIntoView({block: 'center', behavior: 'instant',})
OK, list scrolls and gets rendered correct.

temp2.element(14985).scrollIntoView({block: 'center', behavior: 'instant',})
NOK, list is blanked no elements rendered. Any value >= 14985
At the same time as this problem theres also a printput : err ResizeObserver loop completed with undelivered notifications.
in the console.log

Same problem with scrollToIndex.

Getting a ref to the scrollable element above and using:
scrollabeRef.scrollTop = 37 * 14985 is working

lit-virtualizer is rendered in a lit component as :

            <lit-virtualizer
                .items=${this.options.option}
                .renderItem=${renderItem}
            ></lit-virtualizer>

The Scrollable element is outside the host component.

Reproduction

https://lit.dev/playground/#project=W3sibmFtZSI6InJlcHJvLnRzIiwiY29udGVudCI6ImltcG9ydCB7aHRtbCwgY3NzLCBMaXRFbGVtZW50fSBmcm9tICdsaXQnO1xuaW1wb3J0IHtjdXN0b21FbGVtZW50LCBwcm9wZXJ0eX0gZnJvbSAnbGl0L2RlY29yYXRvcnMuanMnO1xuaW1wb3J0IHR5cGUgeyBMaXRWaXJ0dWFsaXplciB9IGZyb20gJ0BsaXQtbGFicy92aXJ0dWFsaXplcic7XG5pbXBvcnQgJ0BsaXQtbGFicy92aXJ0dWFsaXplcic7XG5cbkBjdXN0b21FbGVtZW50KCd4LXJlcHJvJylcbmV4cG9ydCBjbGFzcyBYUmVwcm8gZXh0ZW5kcyBMaXRFbGVtZW50IHtcbiAgc3RhdGljIHN0eWxlcyA9IGNzc2BkaXYgeyBoZWl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4wXCJcbiAgfVxufSIsImhpZGRlbiI6dHJ1ZX1d

Workaround

Using scrollTop on the scrollable (but is not nice because the scrollable is outside the component and we want to scroll from inside the component)

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

2.0.14

Browser/OS/Node environment

edge
chrome

(Reproduction playground does not work at all on firefox when scroll to for example 1000, not sure if this is another issue or problem with repro!?)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Lit playground and reproduce the failure through lit-virtualizer's element(x).scrollIntoView and scrollToIndex entry points, comparing index 14984 with 14985. Investigate the accompanying ResizeObserver warning and verify that far-away elements render correctly without the blank list or warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.