Skip to content

Keyboard navigation, fixed columns, virtual scrolling of the columns, typed API

Latest

Choose a tag to compare

@komarovalexander komarovalexander released this 16 Nov 15:54
· 4 commits to master since this release
f08ee95

ka-table 13.0.0 is a major release: the table becomes keyboard accessible, gets fixed columns and virtual scrolling of the columns, a typed API without any, themes in plain CSS and many fixes. Thank you to everyone who reported issues and suggested features: all the open issues are resolved in this release!

npm install ka-table@13

13.0.0 has breaking changes, so please read the migration guide before upgrading from 12.x: it shows what to change with "before / after" examples.

Highlights

Keyboard navigation and accessibility

The table is a WAI-ARIA grid with a single Tab stop: the arrows move the focus between the cells, Enter and F2 open the editors, Enter, Space and the arrows expand and collapse the groups and the tree rows. Sorting, groups, the tree, paging and the header filter have ARIA roles, states and names, the validation messages are announced. Demo

Fixed columns and virtual scrolling of the columns

<Table
  columns={[{ key: 'id', title: 'ID', width: 80, fixed: 'left' }, ...otherColumns]}
  virtualScrolling={{ enabled: true, horizontal: true }}
  ...
/>

Only the visible columns are rendered: with 500 columns a table mounts in ~50 ms instead of ~350 ms (#495, #504). Demos: Fixed Column, Many Columns

The state follows the parent

A table without dispatch applies the props which the parent changes and keeps its sorting, column widths and edited data when the parent re-renders (#480, #482). useTableSelector shows a part of the state of the table outside of it:

const table = useTable<Row>();
const selectedRows = useTableSelector(table, (props) => props.selectedRows);

Typed API

The type of the rows is inferred from data, the values of the cells and the keys of the rows are unknown instead of any, the actions are the TableAction union. The whole public API has JSDoc, so your editor shows what every prop, column field and action does.

Themes in plain CSS

style.css declares every colour and size as a --ka-* custom property, a theme overrides them. A dark theme is included:

import 'ka-table/style.css';
import 'ka-table/themes/dark.css'; // and the class ka-dark on the table or an ancestor

The default look is refreshed: hover colours of the rows, more visible selection, active page and focus, styled editors and filter inputs. Dark Theme demo

Faster

  • getData() of 10 000 rows with search, sorting and paging: ~9 ms instead of ~125 ms.
  • Filtering, sorting and grouping run again only when the props which they use change.
  • memoizedRows: rows and cells are re-rendered only when their own props change. Demo
  • Resizing a column (#475) and scrolling horizontally don't render the rows again.

And more

  • The comparator of sort gets the rows: (valueA, valueB, rowDataA, rowDataB) (#477).
  • oddEvenRows="treeRoots" stripes a tree by its roots (#479).
  • Drag and drop by touches on Android (#328), group summaries with the group panel (#336).
  • Fixes of selection, trees, groups, editing, validation, dates and drag and drop.
  • AGENTS.md in the package: notes for AI coding agents about this version.

Breaking changes

  1. React 18 or 19 is required.
  2. Keyboard navigation is enabled by default (keyboardNavigation={false} turns it off).
  3. A table without dispatch applies all the props which the parent changes.
  4. The values of the cells and the keys of the rows are unknown instead of any.
  5. Fixes of the data processing change some results (search, ungrouping, collapsing, dates).
  6. The package is built for ES2019 and has exports.
  7. style.css is plain CSS with custom properties, the package has no Sass files.

The migration guide describes each of them, the changelog lists every change.

Thank you

Thanks to everyone who opened these issues, they shaped this release: #328, #336, #475, #477, #479, #480, #482, #495, #504!