Skip to content

Commit 60e8535

Browse files
authored
fix: Fix collection dirty node tracking with suspense (#8892)
1 parent f36100b commit 60e8535

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

packages/@react-aria/collections/src/Document.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,14 @@ export class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extend
461461
}
462462

463463
private removeNode(node: ElementNode<T>): void {
464-
if (node.node == null) {
465-
return;
466-
}
467-
468464
for (let child of node) {
469465
this.removeNode(child);
470466
}
471467

472-
let collection = this.getMutableCollection();
473-
collection.removeNode(node.node.key);
468+
if (node.node) {
469+
let collection = this.getMutableCollection();
470+
collection.removeNode(node.node.key);
471+
}
474472
}
475473

476474
/** Finalizes the collection update, updating all nodes and freezing the collection. */
@@ -508,12 +506,16 @@ export class Document<T, C extends BaseCollection<T> = BaseCollection<T>> extend
508506
this.addNode(element);
509507
}
510508

509+
if (element.node) {
510+
this.dirtyNodes.delete(element);
511+
}
512+
511513
element.isMutated = false;
514+
} else {
515+
this.dirtyNodes.delete(element);
512516
}
513517
}
514518

515-
this.dirtyNodes.clear();
516-
517519
// Finally, update the collection.
518520
if (this.nextCollection) {
519521
this.nextCollection.commit(this.firstVisibleChild?.node?.key ?? null, this.lastVisibleChild?.node?.key ?? null, this.isSSR);

0 commit comments

Comments
 (0)