Skip to content

refactor(tables): decompose RuiDataTable into sub-components with per-concern context#492

Open
kelsos wants to merge 2 commits intorotki:mainfrom
kelsos:refactor/data-table-decompose
Open

refactor(tables): decompose RuiDataTable into sub-components with per-concern context#492
kelsos wants to merge 2 commits intorotki:mainfrom
kelsos:refactor/data-table-decompose

Conversation

@kelsos
Copy link
Copy Markdown
Member

@kelsos kelsos commented Apr 15, 2026

Summary

  • Decompose the monolithic RuiDataTable template into 7 focused sub-components (RuiDataTableBody, RuiDataTableRow, RuiDataTableCell, RuiDataTableGroupRow, RuiDataTableEmptyRow, RuiDataTableExpandedRow, RuiDataTableLoadingRow)
  • Split the single DataTableContext into 6 per-concern provide/inject pairs (Styling, Columns, Selection, Expansion, Grouping, RowIdentity), each sub-component now only injects what it needs
  • Pre-compute per-column tdClass to eliminate per-cell tv() calls, move itemSlotKeys to context as Set<string> for O(1) lookups, and pass rowId from parent row to avoid redundant getRowId calls
  • Fix story v-model reactivity bug for expanded/group/collapsed bindings, add 8 missing stories, and replace hardcoded test data with deterministic generated fixtures across stories and e2e tests

Test plan

  • pnpm run typecheck passes
  • pnpm run test:run — 1072 unit tests pass
  • pnpm run test:e2e — 262 e2e tests pass
  • Verify stories render correctly in Storybook (pnpm run storybook)

kelsos added 2 commits April 15, 2026 19:07
…oncern context

Decompose the monolithic RuiDataTable template into focused sub-components
(Body, Row, Cell, GroupRow, EmptyRow, ExpandedRow, LoadingRow) and split the
single DataTableContext into 6 per-concern injection pairs (Styling, Columns,
Selection, Expansion, Grouping, RowIdentity).

Performance optimizations:
- Pre-compute per-column tdClass to eliminate per-cell tv() calls
- Move itemSlotKeys to context as Set<string> for O(1) lookups
- Pass rowId from parent row to cell to avoid redundant getRowId calls
- Remove unused ui field from context

Stories:
- Fix v-model reactivity bug for expanded/group/collapsed bindings
- Add stories for search, rounded variants, disabled rows, multi-page
  select, custom item class, hidden header/footer, and grouped with
  expand button position
- Replace hardcoded team names with generated deterministic test data
Replace hardcoded user data in e2e table-configs with deterministic
generated data using the same pattern as the story fixtures. Remove
unused sampleData export. Update search tests to use new names.
@kelsos kelsos requested a review from a team as a code owner April 15, 2026 18:10
kelsos added a commit that referenced this pull request Apr 21, 2026
Extracts the ad-hoc row arrays used by RuiDataTable stories and the
example-app e2e suite into small generator functions driven by a fixed
list of names/titles/roles, producing deterministic rows. Uses the same
fixture set across stories and e2e so a test searching for "Alice"
finds the same rows whether Storybook or Playwright is driving.

Also fixes a stale-binding bug in the stories' `render`: `v-model:expanded`,
`v-model:group` and `v-model:collapsed` bound to `args.*` directly
instead of the `computed` refs returned from `setup`, so changes from
the table wouldn't re-render. Now bound to the local computed refs.

Adds eight stories that already work against the existing DataTable
props: `WithSearch`, `RoundedSmall`, `RoundedLarge`, `DisabledRows`,
`MultiPageSelect`, `CustomItemClass`, `HiddenHeaderAndFooter`,
`GroupedWithExpandButtonEnd`. Useful for Storybook visual review and
future interaction tests.

Cherry-picked from #492 — only the fixture / story-data portions; the
broader DataTable decomposition stays in review.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant