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 11:42:04 UTC

[superset] branch master updated: 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 master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 59ca7861c0 fix: dashboard filter value is cleared when 2 similar dashboards opened in succession (#21461)
59ca7861c0 is described below

commit 59ca7861c0ec47a574c9f033a843ea1b726752f2
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)
---
 .../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 f28c5d47cd..1b13f0583a 100644
--- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx
+++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/index.tsx
@@ -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,
   );
@@ -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];
@@ -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);