Skip to content

Commit aa09f7b

Browse files
author
Asif Ansari
committed
fix: address deferred minor review findings — doc accuracy, redundant casts, rowMeta in edit params, stable empty map, role=status
- docs: soften inaccurate "TypeScript compile error" claim in grid-row-meta.md and row.md; _hasChildren resolves to unknown, not a compile error - docs: replace `as any` cast in migration example with `as Record<string, unknown>` - docs: narrow pagination localeText coverage claim — ARIA labels and button titles remain hardcoded - Cell: remove 3 redundant `as React.ReactNode` casts (renderCell, renderEditCell, formattedValue) - Cell: pass rowMeta to renderEditCell params (was already passed to renderCell) - types: drop redundant Partial<> wrapper on localeText (all GridLocaleText fields are already optional) - DataGrid: hoist fallback rowMetaMap to module-level EMPTY_ROW_META_MAP for stable identity on flat grids - CellErrorBoundary: change role="alert" to role="status" (polite live region; avoids N simultaneous interruptions) - tests: add ArrowDown-at-last-row boundary test to useGridKeyboardNavigation - demo: update Advanced Charts Integration badge from Q2 2026 to Q1 2027
1 parent bdcd1b0 commit aa09f7b

9 files changed

Lines changed: 25 additions & 12 deletions

File tree

‎demo/Home.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export default function Home(_props: HomeProps) {
5050
];
5151

5252
const comingSoon = [
53-
{ badge: 'Q2 2026', name: 'Advanced Charts Integration', desc: 'Native sparklines and trend charts directly inside grid cells.' },
53+
{ badge: 'Q1 2027', name: 'Advanced Charts Integration', desc: 'Native sparklines and trend charts directly inside grid cells.' },
5454
{ badge: 'Q3 2026', name: 'Interactive Pivot Builder', desc: 'Intuitive drag-and-drop interface for end-user analytics.' },
5555
{ badge: 'Q4 2026', name: 'Native PDF Reporting', desc: 'Automated PDF generation with customizable layouts.' }
5656
];

‎docs/architecture/grid-row-meta.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ renderCell: (params) => {
6666

6767
## Runtime shim (v1.1 only)
6868

69-
The underscore fields (`_hasChildren`, `_treeDepth`, etc.) continue to be injected onto the row object at runtime in v1.1. They are no longer declared on `GridRowModel`, so TypeScript strict-mode users get a compile error when accessing them. JS users or users who cast with `as any` see no change.
69+
The underscore fields (`_hasChildren`, `_treeDepth`, etc.) continue to be injected onto the row object at runtime in v1.1. They are no longer declared on `GridRowModel`; because `GridRowModel` retains `[key: string]: unknown`, accessing `params.row._hasChildren` resolves to `unknown` rather than producing a TypeScript compile error. Assignment to a typed variable (e.g. `const x: boolean = params.row._hasChildren`) and arithmetic will error; truthiness checks will not. Migrate to `params.rowMeta?.hasChildren` for the typed path.
7070

7171
**The runtime injection will be removed in v2.0.** Migrate to `params.rowMeta` before upgrading to v2.
7272

‎docs/components/pagination.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ You can replace the internal pagination UI using the `pagination` slot:
3535

3636
## 🌍 Internationalisation
3737

38-
Pass `localeText` on `<DataGrid />` to override all user-visible strings in the Pagination component:
38+
Pass `localeText` on `<DataGrid />` to override the text labels in the Pagination component (rows-per-page, range, and page-counter labels). Note: ARIA labels (`aria-label="Pagination"`, `aria-label="Rows per page"`) and button titles (`title="Previous page"`, `title="Next page"`) are currently hardcoded and not overrideable via `localeText`.
3939

4040
| Key | Type | Default |
4141
| :--- | :--- | :--- |

‎docs/components/row.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ When `getDetailPanelContent` is provided, the `<Row />` renders an expandable co
3434

3535
The internal hierarchy fields (`_hasChildren`, `_treeDepth`, `_isExpanded`, `_groupingField`, `_groupingValue`, `_descendantCount`, `_isGroupRow`) are no longer typed on `GridRowModel`. They will be removed from the runtime row object in v2.0.
3636

37-
**Before (still works at runtime in v1.1, TypeScript compile error in strict mode):**
37+
**Before (still works at runtime in v1.1 — `params.row._hasChildren` is `unknown`, not `boolean`; assignment to typed variables and arithmetic will error, truthiness checks will not):**
3838

3939
```tsx
4040
renderCell: (params) => {
41-
const hasChildren = (params.row as any)._hasChildren;
41+
// v1.1 accepts this at runtime; _hasChildren resolves to unknown via [key: string]: unknown
42+
const hasChildren = (params.row as Record<string, unknown>)._hasChildren;
4243
return hasChildren ? <GroupIcon /> : params.value;
4344
}
4445
```

‎lib/components/Cell/Cell.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,9 @@ function CellImpl<R extends GridRowModel = GridRowModel>(props: CellProps<R>) {
222222
field: colDef.field,
223223
colDef,
224224
rowIndex,
225-
colIndex
226-
}) as React.ReactNode
225+
colIndex,
226+
rowMeta,
227+
})
227228
) : (
228229
<GridEditInputCell
229230
value={value}
@@ -247,10 +248,10 @@ function CellImpl<R extends GridRowModel = GridRowModel>(props: CellProps<R>) {
247248
rowIndex,
248249
colIndex,
249250
rowMeta,
250-
}) as React.ReactNode}
251+
})}
251252
</CellErrorBoundary>
252253
) : (
253-
formattedValue as React.ReactNode
254+
formattedValue
254255
)}
255256
</div>
256257
</div>

‎lib/components/Cell/CellErrorBoundary.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class CellErrorBoundary extends React.Component<CellErrorBoundaryProps, C
4040
return (
4141
<div
4242
className="ogx__cell-error"
43-
role="alert"
43+
role="status"
4444
aria-label={`Error in cell: ${this.props.field}`}
4545
title={this.state.error?.message ?? 'Render error'}
4646
>

‎lib/components/DataGrid/DataGrid.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import { GridVirtualRows } from './GridVirtualRows';
2929
import { GridStandaloneColumnPanel } from './GridStandaloneColumnPanel';
3030
import type { DataGridProps, GridRowModel, GridRowId, GridSortDirection, GridColDef, GridRowParams, GridCellParams, GridDataSource, GridAggregationResult, GridFilterModel, GridTreeNode, GridSortItem, GridRowMeta } from '../../types';
3131

32+
const EMPTY_ROW_META_MAP: Map<GridRowId, GridRowMeta> = new Map();
33+
3234
export function DataGrid<R extends GridRowModel = GridRowModel>(props: DataGridProps<R>) {
3335
const {
3436
rows,
@@ -339,7 +341,7 @@ export function DataGrid<R extends GridRowModel = GridRowModel>(props: DataGridP
339341
const rowMetaMap = useMemo<Map<GridRowId, GridRowMeta>>(() => {
340342
if (isTreeData) return treeDataHandlers.rowMetaMap;
341343
if (isRowGrouping) return rowGroupingHandlers.rowMetaMap;
342-
return new Map();
344+
return EMPTY_ROW_META_MAP;
343345
}, [isTreeData, treeDataHandlers.rowMetaMap, isRowGrouping, rowGroupingHandlers.rowMetaMap]);
344346

345347
const pagination = propPagination && !isRowGrouping;

‎lib/hooks/core/useGridKeyboardNavigation.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ describe('useGridKeyboardNavigation — arrow keys', () => {
8686
expect(result.current.focusedCell?.id).toBe('HEADER');
8787
});
8888

89+
it('ArrowDown at last row — no change', () => {
90+
const { result } = renderHook(() => useGridKeyboardNavigation(BASE_PARAMS));
91+
// ROWS has 3 entries; last row id is 3
92+
const lastRow = ROWS[ROWS.length - 1];
93+
act(() => { result.current.setFocusedCell({ id: lastRow.id, field: 'name' }); });
94+
act(() => { result.current.handleKeyDown(keyEvent('ArrowDown')); });
95+
expect(result.current.focusedCell?.id).toBe(lastRow.id);
96+
});
97+
8998
it('ArrowRight moves focusedCell to next column', () => {
9099
const { result } = renderHook(() => useGridKeyboardNavigation(BASE_PARAMS));
91100
act(() => { result.current.setFocusedCell({ id: 1, field: 'name' }); });

‎lib/types/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ export interface DataGridProps<R extends GridRowModel = GridRowModel> {
580580
/** Message displayed when there are no rows to show. */
581581
noRowsLabel?: string;
582582
/** Overrides for user-visible strings (i18n). All fields are optional. */
583-
localeText?: Partial<GridLocaleText>;
583+
localeText?: GridLocaleText;
584584

585585
/** Advanced: The starting internal state of the grid. */
586586
initialState?: import('../state/types').GridInitialState;

0 commit comments

Comments
 (0)