From 73519791b947ad2a6c1ab0eaf850c093a3cedb48 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Tue, 20 Jan 2026 11:15:35 +0100 Subject: [PATCH] Fix: Resolve array mutation bug preventing Grid sorting from working MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- components/DataGrid.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/DataGrid.tsx b/components/DataGrid.tsx index d07aa72..fbc5c4f 100644 --- a/components/DataGrid.tsx +++ b/components/DataGrid.tsx @@ -334,7 +334,8 @@ const DataGrid: React.FC = ({ data }) => { // 2. Sort 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 valB: number | string = '';