Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
fix: dashboard filter value is cleared when 2 similar dashboards open…
Browse files Browse the repository at this point in the history
…ed in succession (apache#21461)
  • Loading branch information
mayurnewase committed Sep 14, 2022
1 parent ae6d2cf commit 59ca786
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ const FilterBar: React.FC<FiltersBarProps> = ({
const dashboardId = useSelector<any, string>(
({ dashboardInfo }) => dashboardInfo?.id,
);
const previousDashboardId = usePrevious(dashboardId);
const canEdit = useSelector<RootState, boolean>(
({ dashboardInfo }) => dashboardInfo.dash_edit_perm,
);
Expand Down Expand Up @@ -283,7 +284,7 @@ const FilterBar: React.FC<FiltersBarProps> = ({
);

useEffect(() => {
if (previousFilters) {
if (previousFilters && dashboardId === previousDashboardId) {
const updates = {};
Object.values(filters).forEach(currentFilter => {
const previousFilter = previousFilters?.[currentFilter.id];
Expand All @@ -310,7 +311,11 @@ const FilterBar: React.FC<FiltersBarProps> = ({
Object.keys(updates).forEach(key => dispatch(clearDataMask(key)));
}
}
}, [JSON.stringify(filters), JSON.stringify(previousFilters)]);
}, [
JSON.stringify(filters),
JSON.stringify(previousFilters),
previousDashboardId,
]);

const dataMaskAppliedText = JSON.stringify(dataMaskApplied);

Expand Down

0 comments on commit 59ca786

Please sign in to comment.