|
| 1 | +# PR #73: Fix DataTable UI Issues - Sorting, Resizing, and Alignment |
| 2 | + |
| 3 | +## 🎯 **Overview** |
| 4 | + |
| 5 | +This hotfix resolves three critical DataTable UI issues reported by the web app team, improving the overall user experience and functionality of the DataTable component. |
| 6 | + |
| 7 | +## 🐛 **Issues Fixed** |
| 8 | + |
| 9 | +### Issue #70: Missing Sorting Indicators ✅ |
| 10 | + |
| 11 | +- **Problem**: No visual indicators for sortable columns or current sort state |
| 12 | +- **Root Cause**: Header groups were memoized, preventing sorting state changes from triggering re-renders |
| 13 | +- **Solution**: |
| 14 | + - Removed memoization from `headerGroups` to ensure sorting indicators update properly |
| 15 | + - Implemented proper sorting icon logic with lucide-react chevrons: |
| 16 | + - `ChevronsUpDown` (opacity 50%) for sortable but unsorted columns |
| 17 | + - `ChevronUp` for ascending sort |
| 18 | + - `ChevronDown` for descending sort |
| 19 | + - No icon for non-sortable columns |
| 20 | + |
| 21 | +### Issue #71: Number Column Right Alignment Not Working ✅ |
| 22 | + |
| 23 | +- **Problem**: `meta.className: 'text-right'` was not being applied to table cells |
| 24 | +- **Root Cause**: Table cell rendering was not applying the `meta.className` property |
| 25 | +- **Solution**: |
| 26 | + - Fixed table cell rendering to apply `meta.className` using `cn()` utility |
| 27 | + - Added proper TypeScript interface for `ColumnMeta` |
| 28 | + - Updated stories to demonstrate left, right, and center alignment |
| 29 | + |
| 30 | +### Issue #72: Column Resizing Handles Not Working ✅ |
| 31 | + |
| 32 | +- **Problem**: Resize handles were visible but not functional |
| 33 | +- **Root Cause**: Missing column sizing state management and poor handle visibility |
| 34 | +- **Solution**: |
| 35 | + - Added `columnSizing` state and `onColumnSizingChange` callback |
| 36 | + - Improved resize handle styling: |
| 37 | + - Increased width from `w-1` to `w-2` for better visibility |
| 38 | + - Changed background from `bg-border` to `bg-muted-foreground/20` |
| 39 | + - Added smooth transitions and better hover effects |
| 40 | + |
| 41 | +## 🔧 **Additional Improvements** |
| 42 | + |
| 43 | +### Custom SVG Icon Replacement |
| 44 | + |
| 45 | +- Replaced custom SVG icons with lucide-react icons across multiple components: |
| 46 | + - **ThemeToggle**: `Sun` and `Moon` icons |
| 47 | + - **NavItem**: `ChevronRight` icon |
| 48 | + - **ErrorBoundary**: `AlertTriangle` icon |
| 49 | +- **Benefits**: Better consistency, smaller bundle size, easier maintenance |
| 50 | + |
| 51 | +### Enhanced DataTable Stories |
| 52 | + |
| 53 | +- Updated column configurations with explicit sorting and alignment settings |
| 54 | +- Added comprehensive examples demonstrating all features: |
| 55 | + - ID & Age columns: Right-aligned numbers with sorting enabled |
| 56 | + - Name & Email columns: Left-aligned text with sorting enabled |
| 57 | + - Status column: Center-aligned badges with sorting disabled |
| 58 | + |
| 59 | +## 🧪 **Testing** |
| 60 | + |
| 61 | +- ✅ **All DataTable tests passing** (19 tests across 3 test files) |
| 62 | +- ✅ **All UI kit tests passing** (1041 tests total) |
| 63 | +- ✅ **Linter clean** (only existing warnings, no new errors) |
| 64 | +- ✅ **Storybook rebuilt** with all fixes included |
| 65 | +- ✅ **Build successful** for both ui-kit and showcase packages |
| 66 | + |
| 67 | +## 📊 **Verification** |
| 68 | + |
| 69 | +The updated Storybook now properly demonstrates: |
| 70 | + |
| 71 | +1. **✅ Sorting Indicators**: |
| 72 | + |
| 73 | + - Sortable columns show `ChevronsUpDown` when unsorted |
| 74 | + - Active sorting shows `ChevronUp` or `ChevronDown` |
| 75 | + - Non-sortable columns show no indicators |
| 76 | + - **Icons now change when clicking column headers** |
| 77 | + |
| 78 | +2. **✅ Column Resizing**: |
| 79 | + |
| 80 | + - Resize handles are now visible with improved styling |
| 81 | + - Hover effects work properly |
| 82 | + - Drag functionality is fully operational |
| 83 | + - **Resize handles are now visible and functional** |
| 84 | + |
| 85 | +3. **✅ Text Alignment**: |
| 86 | + - Numbers (ID, Age): Right-aligned |
| 87 | + - Text (Names, Email): Left-aligned |
| 88 | + - Status badges: Center-aligned |
| 89 | + - **All alignments working correctly** |
| 90 | + |
| 91 | +## 🚀 **Impact** |
| 92 | + |
| 93 | +- **User Experience**: Significantly improved DataTable usability with working sorting indicators and column resizing |
| 94 | +- **Developer Experience**: Better alignment control and consistent icon usage across components |
| 95 | +- **Maintenance**: Reduced custom code with standardized lucide-react icons |
| 96 | +- **Performance**: Optimized rendering for sorting state changes |
| 97 | + |
| 98 | +## 📝 **Breaking Changes** |
| 99 | + |
| 100 | +None. All changes are backward compatible. |
| 101 | + |
| 102 | +## 🔗 **Related Issues** |
| 103 | + |
| 104 | +- Closes #70: [DataTable] Missing Sorting Indicators |
| 105 | +- Closes #71: [DataTable] Number Column Right Alignment Not Working |
| 106 | +- Closes #72: [DataTable] Column Resizing Handles Not Working |
| 107 | + |
| 108 | +## 📋 **Checklist** |
| 109 | + |
| 110 | +- [x] All tests passing |
| 111 | +- [x] Linter clean |
| 112 | +- [x] Storybook updated and tested |
| 113 | +- [x] Documentation updated (stories) |
| 114 | +- [x] No breaking changes |
| 115 | +- [x] Issues verified as resolved |
0 commit comments