Fix: Resolve array mutation bug preventing Grid sorting from working

- Changed result.sort() to result = [...result].sort() to create new array reference
- React now properly detects changes and re-renders sorted data
- All columns (Sell Out, Units, S.O. Δ%, Units Δ%) now sort correctly
- Verified with comprehensive browser testing
This commit is contained in:
Christian Vidal Wolf
2026-01-20 11:15:35 +01:00
parent 15ad483c25
commit 73519791b9
+2 -1
View File
@@ -334,7 +334,8 @@ const DataGrid: React.FC<DataGridProps> = ({ data }) => {
// 2. Sort // 2. Sort
if (sortConfig.key) { if (sortConfig.key) {
result.sort((a, b) => { // Create a copy to avoid mutating the original array and ensure React detects the change
result = [...result].sort((a, b) => {
let valA: number | string = ''; let valA: number | string = '';
let valB: number | string = ''; let valB: number | string = '';