Skip to content

Commit 6991954

Browse files
committed
docs(components): describeCell says when the table asks it, and that the provider value's identity matters (#35689)
Claude-Session: https://claude.ai/code/session_01QsR2jUc3qp6bHKSWijbjds Co-authored-by: Claude <noreply@anthropic.com>
1 parent 65b9199 commit 6991954

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

‎ui/packages/components/src/context/gridCellSelection.tsx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,15 @@ export interface GridReferenceCells {
109109
}
110110

111111
export interface GridCellSelection {
112-
/** The host's facts for one cell; asked when the reader acts on it, never per render. */
112+
/**
113+
* The host's facts for one cell. The table asks for them when the reader
114+
* acts on a cell (an edit, a key, a paste), and for the selected cell's
115+
* `aria-readonly` (objectstack#35689): once as the cell becomes selected,
116+
* and again when its row is re-read or the provider's value is a new
117+
* object. The value's identity is part of this contract: keep it stable
118+
* across renders (memoise it) and hand a new one only when an answer may
119+
* have changed, or the selected cell is asked on every render.
120+
*/
113121
describeCell?: (row: any, columnKey: string) => GridCellFacts | null | undefined;
114122
/** Called when a cell becomes the selected one (a host may prefetch what an edit will need). */
115123
onCellSelect?: (row: any, columnKey: string) => void;

‎ui/packages/components/src/renderers/complex/data-table.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3733,7 +3733,8 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
37333733
// (`GridCellSelection.describeCell`), for its `aria-readonly`. Asked as a
37343734
// cell becomes selected, and again only when what the answer reads changes:
37353735
// the row is re-read, or the host hands the grid a new value (an answer it
3736-
// was waiting on arrived). Never asked per render; every render reads this.
3736+
// was waiting on arrived). Not asked per render (a host keeps its value
3737+
// stable: `GridCellSelection.describeCell`); every render reads this.
37373738
const selectedRow = selectedPos ? paginatedData[selectedPos.rowIndex] : undefined;
37383739
const selectedColumnKey = selectedPos ? columns[selectedPos.colIndex].accessorKey : undefined;
37393740
const [selectedHostReadOnly, setSelectedHostReadOnly] = useState<{ row: unknown; columnKey: string } | null>(null);
@@ -5275,7 +5276,7 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
52755276
// objectstack#35689 — a read-only cell says so to assistive tech, in the
52765277
// grid only, from the table's own facts. The selected cell (the one a
52775278
// reader moves to) adds the host's, asked when it became selected
5278-
// (`selectedHostReadOnly`: `describeCell` is never asked per render).
5279+
// (`selectedHostReadOnly`: `describeCell` is not asked per render).
52795280
const cellReadOnly = keyboardNavigation
52805281
&& (!isEditable || (isSelectedCell && selectedHostReadOnly !== null
52815282
&& selectedHostReadOnly.row === row && selectedHostReadOnly.columnKey === col.accessorKey));

0 commit comments

Comments
 (0)