krmmkr commented on code in PR #44216:
URL: https://github.com/apache/superset/pull/44216#discussion_r4001467718


##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/useFilterControlFactory.tsx:
##########
@@ -37,9 +39,26 @@ export const useFilterControlFactory = (
   onClearAllComplete?: (filterId: string) => void,
 ) => {
   const filters = useFilters();
+  const dashboardLayout = useSelector<RootState, DashboardLayout>(
+    state => state.dashboardLayout?.present || {},
+  );
+
+  const canvasFilterIds = useMemo(() => {
+    const ids = new Set<string>();
+    Object.values(dashboardLayout).forEach(item => {
+      if (item?.type === FILTER_TYPE && item?.meta?.filterId) {
+        ids.add(String(item.meta.filterId));
+      }
+    });
+    return ids;
+  }, [dashboardLayout]);
+
   const filterValues = useMemo(
-    () => Object.values(filters) as (Filter | Divider)[],
-    [filters],
+    () =>
+      (Object.values(filters) as (Filter | Divider)[]).filter(
+        filter => isFilterDivider(filter) || !canvasFilterIds.has(filter.id),
+      ),

Review Comment:
   filters comes from Redux nativeFilters.filters, which contains only active, 
currently configured filters.
   If a filter was deleted from native filters, it does not exist in filters to 
begin with. It is not rendered in the FilterBar because it was deleted, not 
because of canvasFilterIds.
   If a filter exists in filters and is bound to a canvas card, the canvas card 
displays it and it is excluded from the FilterBar as intended. It does not 
render an unusable placeholder.
   The only time a canvas card shows a placeholder is when the referenced 
filter does not exist in nativeFilters (i.e. it was deleted), in which case the 
filter wouldn't be in the FilterBar anyway.



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to