fix(data-table): update table body immediately when toggling columns#6253
Conversation
DataTableRow's React.memo did not depend on columnVisibility. TanStack row references stay stable when visible columns change, so the table body did not refresh after View -> Toggle columns until another action rebuilt the column definitions. Capture a visible column id signature (visibleColumnIds) outside the memo and compare it, matching the existing isSelected snapshot pattern. All tables that use DataTableRow pick up the fix.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough
ChangesData table row visibility
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Important
📝 Description
On list pages such as Channels, using View → Toggle columns updates the header, but the table body does not follow right away. A full refresh, or another action that rebuilds column definitions (for example the sensitive-data visibility button on Channels), is needed before the body matches the selected columns.
This is the same class of bug as #5524 (row selection not updating).
DataTableRowuses a customReact.memocomparator, and TanStack Table row objects keep a stable reference whencolumnVisibilitychanges. Without a visible-column dependency, the memo skips the update andgetVisibleCells()does not run again.Fix, aligned with the
isSelectedsnapshot in #5524:DataTableRow, build avisibleColumnIdssignature fromrow.getVisibleCells()on each renderChange is limited to the shared
data-table-row.tsx. Every table that renders throughDataTableRow(Channels, API Keys, Users, usage logs customrenderRow, etc.) benefits; feature-specific table logic is unchanged.🚀 Type of change
🔗 Related Issue
✅ Checklist
📸 Proof of Work
Local checks:
cd web/default bun run typecheck bunx oxlint -c .oxlintrc.json src/components/data-table/core/data-table-row.tsxbun run typecheckpassedSuggested manual check:
Summary by CodeRabbit