This is an automated email from the ASF dual-hosted git repository.

amitmiran pushed a commit to branch 1.3
in repository https://gitbox.apache.org/repos/asf/superset.git

commit fd6abcf29b39bffa8f0b2d674f757e2c9122699f
Author: Kamil Gabryjelski <[email protected]>
AuthorDate: Thu Jul 1 14:47:14 2021 +0200

    fix(native-filters): chartsInScope were not recalculated in some cases 
(#15498)
    
    * fix(native-filters): chartsInScope were not recalculated in some cases
    
    * Small refactor
    
    (cherry picked from commit 0ff3253afd7dfe54421ea598dffe5101969b5e38)
---
 .../DashboardBuilder/DashboardContainer.tsx        | 22 ++++++++++++----------
 .../components/gridComponents/ChartHolder.jsx      |  2 +-
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git 
a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
 
b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
index 6273d09..9338433 100644
--- 
a/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
+++ 
b/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx
@@ -68,22 +68,24 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ 
topLevelTabs }) => {
   }, [getLeafComponentIdFromPath(directPathToChild)]);
 
   // recalculate charts and tabs in scopes of native filters only when a scope 
or dashboard layout changes
-  const nativeFiltersValues = Object.values(nativeFilters);
-  const scopes = nativeFiltersValues.map(filter => filter.scope);
+  const filterScopes = Object.values(nativeFilters).map(filter => ({
+    id: filter.id,
+    scope: filter.scope,
+  }));
   useEffect(() => {
     if (
       !isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS) ||
-      nativeFiltersValues.length === 0
+      filterScopes.length === 0
     ) {
       return;
     }
-    const filterScopes = nativeFiltersValues.map(filter => {
-      const filterScope = filter.scope;
+    const scopes = filterScopes.map(filterScope => {
+      const { scope } = filterScope;
       const chartsInScope: number[] = getChartIdsInFilterScope({
         filterScope: {
-          scope: filterScope.rootPath,
+          scope: scope.rootPath,
           // @ts-ignore
-          immune: filterScope.excluded,
+          immune: scope.excluded,
         },
       });
       const tabsInScope = findTabsWithChartsInScope(
@@ -91,13 +93,13 @@ const DashboardContainer: FC<DashboardContainerProps> = ({ 
topLevelTabs }) => {
         chartsInScope,
       );
       return {
-        filterId: filter.id,
+        filterId: filterScope.id,
         tabsInScope: Array.from(tabsInScope),
         chartsInScope,
       };
     });
-    dispatch(setInScopeStatusOfFilters(filterScopes));
-  }, [JSON.stringify(scopes), JSON.stringify(dashboardLayout)]);
+    dispatch(setInScopeStatusOfFilters(scopes));
+  }, [JSON.stringify(filterScopes), dashboardLayout, dispatch]);
 
   const childIds: string[] = topLevelTabs
     ? topLevelTabs.children
diff --git 
a/superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx 
b/superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx
index 32b0795..84d121c 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/ChartHolder.jsx
@@ -130,7 +130,7 @@ const FilterFocusHighlight = React.forwardRef(
 
     if (focusedNativeFilterId) {
       if (
-        nativeFilters.filters[focusedNativeFilterId].chartsInScope.includes(
+        nativeFilters.filters[focusedNativeFilterId].chartsInScope?.includes(
           chartId,
         )
       ) {

Reply via email to