Compare commits

...
Author SHA1 Message Date
Ken 8397677049 perf: Skip observing style-changes 2026-11-03 14:31:18 +01:00
Ken 2bbf17e8b0 perf(DataGrid.Table): Optimize table rebuild 2026-11-02 16:23:44 +01:00
2 changed files with 9 additions and 2 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
"@navikt/ds-react": patch
---
DataGrid.Table: Keyboard navigation no longer rebuilds the internal grid map on every arrow key press, improving responsiveness in large tables.
@@ -5,7 +5,9 @@ import { type GridCache, buildTableGridMap } from "../helpers/table-grid-nav";
/**
* Manages the table grid cache and observes DOM changes that require grid rebuilding.
* Watches for structural changes (rows/cells added/removed) and attribute changes
* (colspan, rowspan, hidden, style) that affect grid layout and focusability.
* (colspan, rowspan, hidden) that affect grid layout.
* Inline `style` is intentionally not observed: focus navigation writes
* scroll-margin on every move, and the grid never reads styles.
*/
function useGridCache(tableRef: HTMLTableElement | null, enabled: boolean) {
const gridCacheRef = useRef<GridCache>({
@@ -34,7 +36,7 @@ function useGridCache(tableRef: HTMLTableElement | null, enabled: boolean) {
subtree: true,
childList: true,
attributes: true,
attributeFilter: ["colspan", "rowspan", "hidden", "style"],
attributeFilter: ["colspan", "rowspan", "hidden"],
});
return () => {