diff --git a/src/frontend/src/tables/InvenTreeTable.tsx b/src/frontend/src/tables/InvenTreeTable.tsx index 65cff57c19..d290eafb48 100644 --- a/src/frontend/src/tables/InvenTreeTable.tsx +++ b/src/frontend/src/tables/InvenTreeTable.tsx @@ -333,9 +333,6 @@ export function InvenTreeTable>({ }); } - const columnNames: string = cols.map((col) => col.accessor).join(','); - setColumnHash(hashString(columnNames)); - return cols; }, [ columns, @@ -345,6 +342,13 @@ export function InvenTreeTable>({ tableState.selectedRecords ]); + useEffect(() => { + const columnNames: string = dataColumns + .map((col: any) => col.accessor) + .join(','); + setColumnHash(hashString(columnNames)); + }, [dataColumns]); + // Callback when column visibility is toggled const toggleColumn = useCallback( (columnName: string) => { @@ -373,6 +377,13 @@ export function InvenTreeTable>({ getInitialValueInEffect: false }); + // Reset column ordering and custom widths when the component is mounted + // Ref: https://github.com/icflorescu/mantine-datatable/issues/759#issuecomment-4148942070 + useEffect(() => { + tableColumns.resetColumnsOrder(); + tableColumns.resetColumnsWidth(); + }, []); + // Reset the pagination state when the search term changes useEffect(() => { tableState.setPage(1);