Skip to content

Commit

Permalink
fix timing of column order setting
Browse files Browse the repository at this point in the history
  • Loading branch information
gilluminate committed Jan 9, 2025
1 parent 74cf894 commit 899ec72
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export const DatamapReportTable = () => {

const [
exportMinimalDatamapReport,
{ isLoading: isExportingReport, isSuccess: isExportReportSuccess },
{ isLoading: isExportingReport, isError: isExportReportError },
] = useExportMinimalDatamapReportMutation();

const { data, totalRows } = useMemo(() => {
Expand Down Expand Up @@ -208,15 +208,17 @@ export const DatamapReportTable = () => {

const columns = useMemo(
() =>
getDatamapReportColumns({
onSelectRow: (row) => setSelectedSystemId(row.fides_key),
getDataUseDisplayName,
getDataCategoryDisplayName,
getDataSubjectDisplayName,
datamapReport,
customFields,
isRenaming: isRenamingColumns,
}),
datamapReport
? getDatamapReportColumns({
onSelectRow: (row) => setSelectedSystemId(row.fides_key),
getDataUseDisplayName,
getDataCategoryDisplayName,
getDataSubjectDisplayName,
datamapReport,
customFields,
isRenaming: isRenamingColumns,
})
: [],
[
getDataUseDisplayName,
getDataSubjectDisplayName,
Expand Down Expand Up @@ -274,7 +276,7 @@ export const DatamapReportTable = () => {
},
},
}).then(() => {
if (isExportReportSuccess) {
if (!isExportReportError) {
onExportReportClose();
}
});
Expand Down Expand Up @@ -303,7 +305,7 @@ export const DatamapReportTable = () => {
});

useEffect(() => {
if (groupBy && !!tableInstance) {
if (groupBy && !!tableInstance && !!datamapReport) {
if (tableInstance.getState().columnOrder.length === 0) {
const tableColumnIds = tableInstance.getAllColumns().map((c) => c.id);
setColumnOrder(getColumnOrder(groupBy, tableColumnIds));
Expand All @@ -314,7 +316,7 @@ export const DatamapReportTable = () => {
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [groupBy, tableInstance]);
}, [groupBy, tableInstance, datamapReport]);

useEffect(() => {
// changing the groupBy should wait until the data is loaded to update the grouping
Expand Down

0 comments on commit 899ec72

Please sign in to comment.