@omnigrid/core 0.1.19 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -310,6 +310,7 @@ export interface GridOptions<T> {
310
310
  /** Row data; omitted or null means an initial load is pending. */
311
311
  data?: T[] | null;
312
312
  columns: ColumnDef<T>[];
313
+ /** Returns a stable row ID; defaults to the row's current index. Use a stable ID to preserve row identity when rows are reordered. */
313
314
  getRowId?: (row: T, index: number) => RowId;
314
315
  rowHeight?: number;
315
316
  /** Rows to render beyond the visible viewport (top + bottom buffer). @default 5 */
@@ -107,14 +107,14 @@ export class Virtualizer {
107
107
  };
108
108
  }
109
109
  getColumnWidths(columns, viewportWidth) {
110
- // Cache by first column identity + viewportWidth. Column objects are stable
111
- // across scroll frames (replaced atomically on setColumns), so this avoids
112
- // re-running the expensive flex-distribution loop on every scroll frame
113
- // for the three column partitions (pinnedLeft, scrollable, pinnedRight).
110
+ // Column objects are stable across scroll frames, so validate each
111
+ // identity before reusing cached widths. Checking only the first column
112
+ // misses updates to other columns when setColumns replaces them.
114
113
  if (columns.length > 0) {
115
114
  const cacheKey = columns[0];
116
115
  const cached = this.widthsCache.get(cacheKey);
117
- if (cached && cached.viewportWidth === viewportWidth && cached.length === columns.length) {
116
+ const columnsUnchanged = cached?.columns.length === columns.length && cached.columns.every((column, index) => column === columns[index]);
117
+ if (cached && cached.viewportWidth === viewportWidth && columnsUnchanged) {
118
118
  return cached.widths;
119
119
  }
120
120
  }
@@ -150,7 +150,7 @@ export class Virtualizer {
150
150
  }
151
151
  const result = this.quantizeWidths(widths);
152
152
  if (columns.length > 0) {
153
- this.widthsCache.set(columns[0], { viewportWidth, length: columns.length, widths: result });
153
+ this.widthsCache.set(columns[0], { viewportWidth, columns: [...columns], widths: result });
154
154
  }
155
155
  return result;
156
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnigrid/core",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Framework-agnostic core engine for OmniGrid",
5
5
  "keywords": [
6
6
  "omnigrid",