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

Method update

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

Source from the content-addressed store, hash-verified

134 }
135
136 update(invalidationContext: InvalidationContext<O>): void {
137 let newCollection = this.virtualizer!.collection as TableCollection<T>;
138
139 // If columnWidths were provided via layoutOptions, update those.
140 // Otherwise, calculate column widths ourselves.
141 if (invalidationContext.layoutOptions?.columnWidths) {
142 for (const [key, val] of invalidationContext.layoutOptions.columnWidths) {
143 if (this.columnWidths.get(key) !== val) {
144 this.columnWidths = invalidationContext.layoutOptions.columnWidths;
145 invalidationContext.sizeChanged = true;
146 break;
147 }
148 }
149 } else if (
150 invalidationContext.sizeChanged ||
151 this.columnsChanged(newCollection, this.lastCollection)
152 ) {
153 let columnLayout = new TableColumnLayout({});
154 this.columnWidths = columnLayout.buildColumnWidths(
155 this.virtualizer!.size.width - this.padding * 2,
156 newCollection,
157 new Map()
158 );
159 invalidationContext.sizeChanged = true;
160 }
161
162 super.update(invalidationContext);
163 }
164
165 protected buildCollection(): LayoutNode[] {
166 this.stickyColumnIndices = [];

Callers

nothing calls this directly

Calls 3

columnsChangedMethod · 0.95
buildColumnWidthsMethod · 0.95
updateMethod · 0.65

Tested by

no test coverage detected