๐ง Shot Table Sort Direction Fix
โ Issue Identified
Problem: Shot table header sorting direction only goes down (descending) and never goes up (ascending).
Root Cause: Incorrect logic in toggleSorting parameter in frontend/src/components/shot/columns.ts
๐ Technical Analysis
The issue was in the TanStack Table toggleSorting method call:
โ Before (Broken)
onClick: () => column.toggleSorting(column.getIsSorted() === 'asc')
Logic:
- When currently ascending โ passes
true โ forces descending
- When currently descending โ passes
false โ should go ascending but doesn't work properly
- When no sort โ passes
false โ goes ascending (this worked)
โ
After (Fixed)
onClick: () => column.toggleSorting(column.getIsSorted() === 'desc')
Logic:
- When currently ascending โ passes
false โ toggles to descending
- When currently descending โ passes
true โ toggles to ascending
- When no sort โ passes
false โ goes ascending
๐ TanStack Table toggleSorting Method
According to TanStack Table documentation:
toggleSorting(desc?: boolean)
- toggleSorting() - cycles: none โ asc โ desc โ none
- toggleSorting(false) - cycles: none โ asc โ desc โ none
- toggleSorting(true) - cycles: none โ desc โ asc โ none
The parameter desc indicates whether to prefer descending sort when toggling from no sort.
โ
Files Fixed
Updated frontend/src/components/shot/columns.ts - Fixed all sortable columns:
- โ
Shot Name column
- โ
Episode column
- โ
Frame Range column
- โ
Frames column (frame count)
- โ
Status column
- โ
Description column
Note: Task status columns are dynamically generated and inherit the same pattern, so they're also fixed.
๐งช Testing Instructions
To verify the fix works correctly:
- Navigate to Shot Table: Go to any project's shots page and switch to table view
- Test Sort Cycle: Click on any sortable column header (e.g., "Shot Name")
- Verify Ascending: First click should sort ascending (AโZ, 1โ9) with up arrow โ
- Verify Descending: Second click should sort descending (ZโA, 9โ1) with down arrow โ
- Verify Clear: Third click should clear sort (original order) with up-down arrow โ
- Test Multiple Columns: Repeat for Episode, Frame Range, Frames, Status, Description
- Visual Feedback: Confirm icons change correctly: โ โ โ โ โ โ โ
๐ฏ Expected Behavior
After the fix, clicking column headers should cycle through:
1. No Sort (โ up-down arrow) โ Original data order
2. Ascending (โ up arrow) โ A-Z, 1-9, earliest-latest
3. Descending (โ down arrow) โ Z-A, 9-1, latest-earliest
4. Back to No Sort (โ up-down arrow)
๐ Related Issue
Note: The same issue exists in frontend/src/components/task/columns.ts and should be fixed there as well for consistency.
This affects the task table sorting behavior in the same way.
โ
Fix Summary
Changed: column.getIsSorted() === 'asc' โ column.getIsSorted() === 'desc'
Result: Proper sort direction cycling with correct visual feedback
Impact: All sortable columns in shot table now work correctly
Status: Ready for testing