fix(data-table): align defaultSort optionality across internal types and fix sort icon direction#841
Conversation
…and fix sort icon direction
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
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)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe data-table sort flow now allows Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/raystack/components/data-table/components/ordering.tsx`:
- Around line 74-80: The sort icon logic in ordering.tsx should treat an
undefined value as ascending instead of falling through to the descending icon.
Update the conditional around value.order in the ordering render so the default
branch maps to SortOrders.ASC, and remove the unnecessary optional chaining on
SortOrders since it is a non-nullable constant. Keep the fix localized to the
icon selection in this component.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b2459c9a-9cfb-4adb-9e8f-9285043e0cf6
📒 Files selected for processing (4)
packages/raystack/components/data-table/components/ordering.tsxpackages/raystack/components/data-table/data-table.tsxpackages/raystack/components/data-table/data-table.types.tsxpackages/raystack/components/data-table/utils/index.tsx
…efault_sort_type_error_fixes

Description
This PR contains two changes to the
data-tablecomponent'sOrderingcontrol and surrounding types.1. Corrected the sort direction icons. In the
Orderingtoggle the ascending/descending icons were swapped — ascending (asc) showed the "align bottom" icon and descending (desc) showed the "align top" icon. They are now correct:ascshowsTextAlignTopIconanddescshowsTextAlignBottomIcon, so the icon matches the actual sort direction.2. Fixed
defaultSorttype-safety issues. ThedefaultSortprop is optional on the publicDataTableProps, but several internal types incorrectly required it (DataTableSortinstead ofDataTableSort | undefined), producing latent type errors and a possible runtime crash in theOrderingcontrol when nodefaultSortis provided.Changes:
Orderingso the direction shown matches the applied sort order.getDefaultTableQueryandhasActiveQueryparameters to optionaldefaultSort?(their bodies already guarded forundefined).TableContextType.defaultSortoptional to match the public prop.sort: defaultSort ? [defaultSort] : []instead of[undefined].Ordering'svalueoptional and guarded its internal accesses (value?.name,value?.order, early-return in the order toggle), preventing a deref of a possibly-undefined value.The public API is unchanged —
defaultSortremains optional and the change is fully backward-compatible.Type of Change
How Has This Been Tested?
raystackpackage; the four changed files (ordering.tsx,data-table.tsx,data-table.types.tsx,utils/index.tsx) produce zero type errors, and no new cross-errors were introduced in any other file.data-table.test.tsx,utils/index.test.tsx,utils/filter-operations.test.tsx).data-view/data-view-betasuites as a sanity check (they keep independent copies of these utils/components) — 59 passed, 1 skipped, unaffected.Checklist:
Screenshots (if appropriate):
[Add screenshots here]
Related Issues
[Link any related issues here using #issue-number]