MCPcopy Index your code
hub / github.com/adobe/react-spectrum / update

Method update

packages/react-stately/src/layout/ListLayout.ts:338–379  ·  view source on GitHub ↗
(invalidationContext: InvalidationContext<O>)

Source from the content-addressed store, hash-verified

336 }
337
338 update(invalidationContext: InvalidationContext<O>): void {
339 let collection = this.virtualizer!.collection;
340
341 // Reset valid rect if we will have to invalidate everything.
342 // Otherwise we can reuse cached layout infos outside the current visible rect.
343 this.invalidateEverything = this.shouldInvalidateEverything(invalidationContext);
344 if (this.invalidateEverything) {
345 this.requestedRect = this.virtualizer!.visibleRect.copy();
346 this.layoutNodes.clear();
347 }
348
349 let options = invalidationContext.layoutOptions;
350 this.rowSize = options?.rowSize ?? options?.rowHeight ?? this.rowSize;
351 this.orientation = options?.orientation ?? this.orientation;
352 this.estimatedRowSize =
353 options?.estimatedRowSize ?? options?.estimatedRowHeight ?? this.estimatedRowSize;
354 this.headingSize = options?.headingSize ?? options?.headingHeight ?? this.headingSize;
355 this.estimatedHeadingSize =
356 options?.estimatedHeadingSize ?? options?.estimatedHeadingHeight ?? this.estimatedHeadingSize;
357 this.loaderSize = options?.loaderSize ?? options?.loaderHeight ?? this.loaderSize;
358 this.dropIndicatorThickness = options?.dropIndicatorThickness ?? this.dropIndicatorThickness;
359 this.gap = options?.gap ?? this.gap;
360 this.padding = options?.padding ?? this.padding;
361
362 this.rootNodes = this.buildCollection();
363
364 // Remove deleted layout nodes
365 if (this.lastCollection && collection !== this.lastCollection) {
366 for (let key of this.lastCollection.getKeys()) {
367 if (!collection.getItem(key)) {
368 let layoutNode = this.layoutNodes.get(key);
369 if (layoutNode) {
370 this.layoutNodes.delete(key);
371 }
372 }
373 }
374 }
375
376 this.lastCollection = collection;
377 this.invalidateEverything = false;
378 this.validRect = this.requestedRect.copy();
379 }
380
381 protected buildCollection(offset: number = this.padding): LayoutNode[] {
382 let collection = this.virtualizer!.collection;

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected