You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2022/09/14 20:41:54 UTC
[superset] 03/03: fix: dashboard filter value is cleared when 2 similar dashboards opened in succession (#21461)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 1.5
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 7d70ea1235874a90ec16e414de723ae09141629f
Author: Mayur <ma...@gmail.com>
AuthorDate: Wed Sep 14 17:11:51 2022 +0530
fix: dashboard filter value is cleared when 2 similar dashboards opened in succession (#21461)
(cherry picked from commit 59ca7861c0ec47a574c9f033a843ea1b726752f2)
---
.../src/dashboard/components/nativeFilters/FilterBar/index.tsx | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx
index 309d75dac9..c6eeedfa15 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx
@@ -246,6 +246,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,
);
@@ -279,7 +280,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];
@@ -306,7 +307,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);