Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions app/components/DataTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,13 @@ const DataTable = forwardRef<DataTableImperativeHandle, DataTableProps>(({
}
});
}
if (showReorder) {
nextColDefs = nextColDefs.map((cd) => (
cd.colId === 'drag' ? { ...cd, hide: false } : cd
));
}
return nextColDefs;
}, [colDefs, collapseColumnFields]);
}, [colDefs, collapseColumnFields, showReorder]);

useEffect(() => {
if (gridApi) {
Expand Down Expand Up @@ -439,27 +444,16 @@ const DataTable = forwardRef<DataTableImperativeHandle, DataTableProps>(({
}, [colApi, columnDefs, gridApi, isFullLength, isPrint, rowData.length, syncVisibleColumns, visibleColumns]);

const toggleReorder = useCallback(() => {
if (!showReorder) {
columnDefs.forEach((col) => {
col.sortable = false;
col.filter = false;
});
colApi.applyColumnState({ state: [{ colId: 'rank', sort: 'asc' }], defaultState: { sort: null } });
gridApi.setColumnDefs(columnDefs);

colApi.setColumnVisible('drag', true);
setShowReorder(true);
} else {
columnDefs.forEach((col) => {
col.sortable = true;
col.filter = true;
});
gridApi.setColumnDefs(columnDefs);
setShowReorder((prev) => !prev);
}, []);

colApi.setColumnVisible('drag', false);
setShowReorder(false);
}
}, [colApi, columnDefs, gridApi, showReorder]);
useEffect(() => {
if (!colApi || !showReorder) return;
colApi.applyColumnState({
state: [{ colId: 'rank', sort: 'asc' }],
defaultState: { sort: null },
});
}, [colApi, showReorder, columnDefs]);

const onRowDragEnd = useCallback(async (event) => {
onReorder(event.node.data, event.overIndex, tableType);
Expand All @@ -473,6 +467,11 @@ const DataTable = forwardRef<DataTableImperativeHandle, DataTableProps>(({
.map((col) => col.getColId())
.filter((col) => !returnedVisibleCols.includes(col));

const dragVisible = returnedVisibleCols.includes('drag');
if (dragVisible !== showReorder) {
setShowReorder(dragVisible);
}

colApi.setColumnsVisible(returnedVisibleCols, true);
colApi.setColumnsVisible(returnedHiddenCols, false);

Expand All @@ -484,7 +483,7 @@ const DataTable = forwardRef<DataTableImperativeHandle, DataTableProps>(({
syncVisibleColumns(returnedVisibleCols);
}
setShowPopover(false);
}, [colApi, syncVisibleColumns]);
}, [colApi, showReorder, syncVisibleColumns]);

const RowActionCellRenderer = useCallback((row) => (
<ActionCellRenderer
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "ipr-client",
"version": "7.5.2",
"version": "7.5.3",
"keywords": [],
"license": "GPL-3.0",
"sideEffects": false,
Expand Down
Loading