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

Method update

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

Source from the content-addressed store, hash-verified

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