Skip to content

Run 6: Item-grid Integration — Byproducts

These additions were required to support item-grid’s use cases and benefit all entity grids going forward:

gridContext + gridContextOverride (DataGrid molecule + entity-data-grid)

Section titled “gridContext + gridContextOverride (DataGrid molecule + entity-data-grid)”
  • Why: NotesCellRenderer and other custom cell renderers may need to read runtime values from params.context
  • Implementation: gridContext is static (factory-time) in EntityDataGridConfig; gridContextOverride is runtime (per-render) in EntityDataGridViewProps. They’re shallow-merged: runtime values take precedence
  • DataGrid change: Added gridContext?: Record<string, unknown> to DataGridRuntimeConfig; passed as context={gridContext} to AG Grid when set
  • Why: Callers need imperative access to the AG Grid API for operations like setColumnsVisible, deselectAll, exportDataAsCsv
  • Implementation: EntityDataGridRef.getGridApi() delegates to DataGridRef.getGridApi() which returns GridApi<T> | null
  • Shim impact: EntityDataGridShimRef extends EntityDataGridRef, so the shim also needed getGridApi() added to its useImperativeHandle

Behavioral Note: Count Label Format Change

Section titled “Behavioral Note: Count Label Format Change”

The search-active count label changed from "1 item" (filtered total only) to "1 of 12 items" (filtered of total). This is a better UX that shows search context. The 3 affected tests and the WithSearch story play function were updated. No visual regressions expected — the label format is an improvement.

ItemGridStaticConfig.height (defaulted to 600 in the old implementation) is now accepted but not passed to entity-data-grid. The grid fills the parent container via flex layout. Callers that relied on the fixed height = 600 default should wrap the component in a sized container or use autoHeight. No current caller other than stories is known to depend on this.

enableRowSelection prop is silently ignored

Section titled “enableRowSelection prop is silently ignored”

The old implementation gated rowSelection: { mode: 'multiRow', headerCheckbox: true } on this prop. In the new implementation, DataGrid always enables multi-row selection. The visual difference: all item-grid instances now show selection checkboxes. This is generally desirable but is a behavioral change for callers that passed enableRowSelection={false} expecting no checkboxes.

useMemo with string key for factory rebuild

Section titled “useMemo with string key for factory rebuild”

The createEntityDataGrid factory is called inside useMemo with a string key (makeFactoryKey). This is a pragmatic workaround for the fact that React’s useMemo doesn’t support object dependency comparison. The factory only rebuilds when the key changes (lookup presence, pageSize, actionsColumn presence, autoHeight). The key approach works for the current use cases but could be simplified if the factory was always stable (e.g., if lookups changed identity without changing presence).

From organisms/item-grid/index.ts:

  • ItemGridHandle — new type export (was not in old index.ts)
  • PendingChanges — re-exported from entity-data-grid (was from use-item-grid-editing)
  • ItemGridEditingHandle — still exported (now from item-grid.tsx not use-item-grid-editing.ts)

From organisms/shared/entity-data-grid/index.ts (unchanged, but note):

  • EntityDataGridRef now has getGridApi() — callers using this type may need to implement it

From organisms/item-grid/index.ts:

  • RowEditState — was exported from use-item-grid-editing.ts, which is now deleted. It’s still available from entity-data-grid/index.ts
  • useItemGridEditing was never in the barrel (only in use-item-grid-editing.ts file-level)

canary.ts impact: The barrel (src/canary.ts) does not currently export from organisms/item-grid. Run 7 should decide whether to add item-grid exports to canary.ts.

molecules/item-grid/select-cell-editor.tsx was deleted. The remaining files in molecules/item-grid/:

  • typeahead-cell-editor.tsx — still canonical for typeahead; no atom-level equivalent exists yet
  • item-grid-columns.tsx — domain column definitions; stays in molecules
  • item-grid-fixtures.ts — test data; stays in molecules
  • drag-header.tsx — drag grip header component; stays in molecules
  • item-grid-molecules.stories.tsx — stories for the above

Run 7 may want to evaluate promoting typeahead-cell-editor.tsx to an atom (it was identified in the analysis as deserving atom-level status).