Skip to content

Conversation

@ajhoddinott
Copy link

If itemCount decreases, for example due to filtering, there are two issues:

  • SizeAndPositionManager lastMeasuredIndex can point to items that no longer exist, causing "index X is outside of range"
  • VirtualList tries to render stale items before refresh() has updated

This fix:

  • Clamps lastMeasuredIndex in updateConfig()
  • Clamps the scroll offset in refresh()

I introduced a derived validItems to filter out stale items. This can be inlined as
{#each items.filter((item) => item.index < itemCount) as item (getKey ? getKey(item.index) : item.index)}
but I felt the line was long and hard to follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant