Skip to content

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

Open
kelsos wants to merge 1 commit into
rotki:mainfrom
kelsos:refactor/data-table-decompose
Open

refactor(tables): decompose RuiDataTable into sub-components with per-concern context#492
kelsos wants to merge 1 commit into
rotki: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 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.
…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
@kelsos kelsos force-pushed the refactor/data-table-decompose branch from ea450d0 to 6f46e19 Compare April 22, 2026 16:24
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.13095% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.73%. Comparing base (2303795) to head (6f46e19).

Files with missing lines Patch % Lines
.../components/tables/data-table/RuiDataTableBody.vue 80.00% 5 Missing ⚠️
.../ui-library/src/components/tables/RuiDataTable.vue 85.18% 4 Missing ⚠️
...ponents/tables/data-table/RuiDataTableGroupRow.vue 90.00% 2 Missing ⚠️
...ry/src/composables/tables/data-table/pagination.ts 97.56% 1 Missing ⚠️
...-library/src/composables/tables/data-table/sort.ts 98.59% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #492      +/-   ##
==========================================
+ Coverage   84.59%   85.73%   +1.13%     
==========================================
  Files         139      147       +8     
  Lines        5062     5263     +201     
  Branches     1507     1554      +47     
==========================================
+ Hits         4282     4512     +230     
+ Misses        780      751      -29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants