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

sadpandajoe pushed a commit to branch 
ultraset-disabled-cross-filter-table-cell-click
in repository https://gitbox.apache.org/repos/asf/superset.git

commit e14dffc01c22b2225ddc666907909d0b3ee767e2
Author: Joe Li <[email protected]>
AuthorDate: Fri Nov 13 19:33:06 2026 +0000

    fix(dashboard): don't emit cross-filters from charts scoped to no other 
chart
    
    A chart whose cross-filter scope targets no other chart (e.g. 
cross-filtering
    disabled for it in the scoping modal) still emitted a cross-filter on click,
    because the dashboard chart only checked the dashboard-level
    crossFiltersEnabled flag. The filter bar then listed an entry that filtered
    nothing. Gate emitCrossFilters on the chart's chartsInScope as well.
    
    Fixes #46197
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
 .../components/gridComponents/Chart/Chart.test.tsx | 41 ++++++++++++++++++++++
 .../components/gridComponents/Chart/Chart.tsx      | 14 ++++++--
 2 files changed, 52 insertions(+), 3 deletions(-)

diff --git 
a/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.test.tsx
 
b/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.test.tsx
index 4d316dd32c7..69470543707 100644
--- 
a/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.test.tsx
+++ 
b/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.test.tsx
@@ -1287,3 +1287,44 @@ test('passes the form data of the last request to 
ChartContainer next to the cur
     expect.objectContaining({ groupby: ['region'] }),
   );
 });
+
+const stateWithCrossFilterScope = (chartsInScope?: number[]) => ({
+  ...defaultState,
+  dashboardInfo: {
+    ...defaultState.dashboardInfo,
+    crossFiltersEnabled: true,
+    metadata: chartsInScope
+      ? {
+          chart_configuration: {
+            [queryId]: {
+              id: queryId,
+              crossFilters: { scope: 'global', chartsInScope },
+            },
+          },
+        }
+      : {},
+  },
+});
+
+test('does not emit cross-filters when the chart cross-filter scope targets no 
other chart', () => {
+  setup({}, stateWithCrossFilterScope([]));
+  expect(capturedChartContainerProps.emitCrossFilters).toBe(false);
+
+  setup({}, stateWithCrossFilterScope([queryId]));
+  expect(capturedChartContainerProps.emitCrossFilters).toBe(false);
+});
+
+test('emits cross-filters when the chart cross-filter scope targets another 
chart', () => {
+  setup({}, stateWithCrossFilterScope([queryId + 1]));
+  expect(capturedChartContainerProps.emitCrossFilters).toBe(true);
+});
+
+test('emits cross-filters when the chart has no cross-filter configuration', 
() => {
+  setup({}, stateWithCrossFilterScope());
+  expect(capturedChartContainerProps.emitCrossFilters).toBe(true);
+});
+
+test('does not emit cross-filters when cross-filtering is disabled on the 
dashboard', () => {
+  setup({}, defaultState);
+  expect(capturedChartContainerProps.emitCrossFilters).toBe(false);
+});
diff --git 
a/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.tsx 
b/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.tsx
index 7ef7c295470..dfc9f8d560b 100644
--- a/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.tsx
+++ b/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.tsx
@@ -235,9 +235,17 @@ const Chart = (props: ChartProps) => {
     (state: RootState) =>
       state.dashboardInfo.common.conf.SUPERSET_WEBSERVER_TIMEOUT as number,
   );
-  const emitCrossFilters = useSelector(
-    (state: RootState) => !!state.dashboardInfo.crossFiltersEnabled,
-  );
+  const emitCrossFilters = useSelector((state: RootState) => {
+    if (!state.dashboardInfo.crossFiltersEnabled) {
+      return false;
+    }
+    // A chart whose cross-filter scope targets no other chart must not emit,
+    // otherwise it creates a filter-bar entry that filters nothing.
+    const chartsInScope =
+      state.dashboardInfo.metadata?.chart_configuration?.[props.id]
+        ?.crossFilters?.chartsInScope;
+    return !chartsInScope || chartsInScope.some(id => id !== props.id);
+  });
   const maxRows: number = useSelector(
     (state: RootState) => state.dashboardInfo.common.conf.SQL_MAX_ROW as 
number,
   );

Reply via email to