Skip to content

Commit

Permalink
fix: index from removed node points to new key (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
piecyk committed Oct 3, 2023
1 parent 106a0be commit 9e974bc
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions packages/virtual-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ export class Virtualizer<
entry: ResizeObserverEntry | undefined,
) => {
const item = this.measurementsCache[this.indexFromElement(node)]
if (!item) {

if (!item || !node.isConnected) {
this.measureElementCache.forEach((cached, key) => {
if (cached === node) {
this.observer.unobserve(node)
Expand All @@ -632,14 +633,6 @@ export class Virtualizer<

const prevNode = this.measureElementCache.get(item.key)

if (!node.isConnected) {
if (prevNode) {
this.observer.unobserve(prevNode)
this.measureElementCache.delete(item.key)
}
return
}

if (prevNode !== node) {
if (prevNode) {
this.observer.unobserve(prevNode)
Expand Down

0 comments on commit 9e974bc

Please sign in to comment.