You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/06/10 00:06:32 UTC

[GitHub] [superset] suddjian commented on a change in pull request #15063: feat(native-filters): Hide filters which don't affect any visible charts

suddjian commented on a change in pull request #15063:
URL: https://github.com/apache/superset/pull/15063#discussion_r648761375



##########
File path: superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx
##########
@@ -80,11 +80,31 @@ const FilterControls: FC<FilterControlsProps> = ({
     element => element.type === TAB_TYPE,
   );
   const showCollapsePanel = dashboardHasTabs && cascadeFilters.length > 0;
-  if (!lastFocusedTabId || !dashboardHasTabs) {
+
+  // we check native filters scopes only on dashboards with tabs
+  if (!dashboardHasTabs) {
     filtersInScope = cascadeFilters;
   } else {
     cascadeFilters.forEach((filter, index) => {
-      if (cascadeFilters[index].tabsInScope?.includes(lastFocusedTabId)) {
+      // Filter is in scope if any of it's charts is visible.
+      // Chart is visible if it's placed in an active tab tree or if it's not attached to any tab.
+      // Chart is in an active tab tree if all of it's ancestors of type TAB are active
+      const isFilterInScope = cascadeFilters[index].chartsInScope?.some(

Review comment:
       ```suggestion
         const isFilterInScope = filter.chartsInScope?.some(
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org