From 259ecea97edfd554a9fab4e7105e80dc72245f2b Mon Sep 17 00:00:00 2001 From: samhere06 Date: Mon, 29 Jun 2026 16:38:40 +0530 Subject: [PATCH 1/2] SimpleTable manual modal edit/delete picks wrong element after filter/sort --- .../SimpleTableManual/SimpleTableManual.tsx | 76 +++++++++---------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx b/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx index 83a2252b..23acea64 100644 --- a/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +++ b/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx @@ -439,20 +439,12 @@ export default function SimpleTableManual(props: PropsWithChildren(array: T[], comparator: (a: T, b: T) => number) { const stabilizedThis = array.map((el, index) => [el, index] as [T, number]); stabilizedThis.sort((a, b) => { + // eslint-disable-next-line @typescript-eslint/no-shadow const order = comparator(a[0], b[0]); if (order !== 0) return order; return a[1] - b[1]; }); - - const newElements = new Array(stabilizedThis.length); - stabilizedThis.forEach((el, index) => { - // Use the original index recorded on the row (set in generateRowsData) - // so that filtering (which shrinks rowData but not `elements`) still maps - // each surviving row to the correct rendered cells. - const originalIndex = (el[0] as any)?.__originalIndex ?? el[1]; - newElements[index] = elements[originalIndex]; - }); - return newElements; + return stabilizedThis.map(([el]) => el); } function _menuClick(event, columnId: string, columnType: string, labelValue: string) { @@ -699,39 +691,39 @@ export default function SimpleTableManual(props: PropsWithChildren 0 && - stableSort(rowData, getComparator(order, orderBy)) - .slice(0) - .map((row, index) => { - return ( - - {row?.map((item, childIndex) => { - const theColKey = displayedColumns[childIndex]; - return ( - - {item} - - ); - })} - {showDeleteButton && ( - -
- { - editMenuClick(event, index); - }} - /> - - editRecord()}>Edit - deleteRecord()}>Delete - -
+ stableSort(rowData, getComparator(order, orderBy)).map((row: any, displayIndex) => { + const originalIndex = row.__originalIndex; + return ( + // eslint-disable-next-line react/no-array-index-key + + {(elements as any[])[originalIndex]?.map((item, childIndex) => { + const theColKey = displayedColumns[childIndex]; + return ( + + {item} - )} - - ); - })} + ); + })} + {showDeleteButton && ( + +
+ { + editMenuClick(event, originalIndex); + }} + /> + + editRecord()}>Edit + deleteRecord()}>Delete + +
+
+ )} +
+ ); + })} {((readOnlyMode && (!rowData || rowData?.length === 0)) || From 1c2e3b49ed389c71df170da4fe9500efb9a97c6b Mon Sep 17 00:00:00 2001 From: samhere06 Date: Mon, 29 Jun 2026 16:59:12 +0530 Subject: [PATCH 2/2] removed unneccessary comments --- .../SimpleTable/SimpleTableManual/SimpleTableManual.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx b/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx index 23acea64..0ed4a9d1 100644 --- a/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +++ b/packages/react-sdk-components/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx @@ -439,7 +439,6 @@ export default function SimpleTableManual(props: PropsWithChildren(array: T[], comparator: (a: T, b: T) => number) { const stabilizedThis = array.map((el, index) => [el, index] as [T, number]); stabilizedThis.sort((a, b) => { - // eslint-disable-next-line @typescript-eslint/no-shadow const order = comparator(a[0], b[0]); if (order !== 0) return order; return a[1] - b[1]; @@ -694,7 +693,6 @@ export default function SimpleTableManual(props: PropsWithChildren { const originalIndex = row.__originalIndex; return ( - // eslint-disable-next-line react/no-array-index-key {(elements as any[])[originalIndex]?.map((item, childIndex) => { const theColKey = displayedColumns[childIndex];