MCPcopy Create free account
hub / github.com/adobe/react-spectrum / update

Method update

packages/@react-spectrum/ai/src/ListLayout.ts:408–452  ·  view source on GitHub ↗
(invalidationContext: InvalidationContext<O>)

Source from the content-addressed store, hash-verified

406 }
407
408 update(invalidationContext: InvalidationContext<O>): void {
409 let collection = this.virtualizer!.collection;
410
411 // Reset valid rect if we will have to invalidate everything.
412 // Otherwise we can reuse cached layout infos outside the current visible rect.
413 this.invalidateEverything = this.shouldInvalidateEverything(invalidationContext);
414 if (this.invalidateEverything) {
415 this.requestedRect = this.virtualizer!.visibleRect.copy();
416 this.layoutNodes.clear();
417 }
418
419 let options = invalidationContext.layoutOptions;
420 this.rowSize = options?.rowSize ?? options?.rowHeight ?? this.rowSize;
421 this.orientation = options?.orientation ?? this.orientation;
422 this.anchorTo = options?.anchorTo ?? this.anchorTo;
423 this.scrollEndThreshold = options?.scrollEndThreshold ?? this.scrollEndThreshold;
424 this.estimatedRowSize =
425 options?.estimatedRowSize ?? options?.estimatedRowHeight ?? this.estimatedRowSize;
426 this.headingSize = options?.headingSize ?? options?.headingHeight ?? this.headingSize;
427 this.estimatedHeadingSize =
428 options?.estimatedHeadingSize ?? options?.estimatedHeadingHeight ?? this.estimatedHeadingSize;
429 this.loaderSize = options?.loaderSize ?? options?.loaderHeight ?? this.loaderSize;
430 this.dropIndicatorThickness = options?.dropIndicatorThickness ?? this.dropIndicatorThickness;
431 this.gap = options?.gap ?? this.gap;
432 this.padding = options?.padding ?? this.padding;
433 this.warnIfReversedHorizontal();
434
435 this.rootNodes = this.buildCollection();
436
437 // Remove deleted layout nodes
438 if (this.lastCollection && collection !== this.lastCollection) {
439 for (let key of this.lastCollection.getKeys()) {
440 if (!collection.getItem(key)) {
441 let layoutNode = this.layoutNodes.get(key);
442 if (layoutNode) {
443 this.layoutNodes.delete(key);
444 }
445 }
446 }
447 }
448
449 this.lastCollection = collection;
450 this.invalidateEverything = false;
451 this.validRect = this.requestedRect.copy();
452 }
453
454 protected buildCollection(offset: number = this.padding): LayoutNode[] {
455 if (this.anchorTo === 'end' && this.orientation === 'vertical') {

Callers

nothing calls this directly

Calls 8

buildCollectionMethod · 0.95
deleteMethod · 0.80
copyMethod · 0.65
getKeysMethod · 0.65
getItemMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected