Skip to content

fix(echarts): guard cross-filter when labelMap entry is missing - #42559

Merged
rusackas merged 2 commits into
apache:masterfrom
chkang83:fix/echarts-guard-cross-filter-labelmap
Aug 28, 2026
Merged

rusackas merged 2 commits into
apache:masterfrom
chkang83:fix/echarts-guard-cross-filter-labelmap

Conversation

@chkang83

Copy link
Copy Markdown
Contributor

SUMMARY

Fixes #42340.

When ECharts charts that share eventHandlers.ts (notably Pie) receive a click whose series name is not in labelMap — e.g. Pie Other, Total, or an empty/missing name — getCrossFilterDataMask still built a data mask. After .filter(Boolean), groupbyValues could be empty while values was non-empty, which led to invalid cross-filters (IN with empty values, or unintended IS NULL because [].every(...) is true). Downstream charts then failed or returned wrong results.
This change returns undefined early when labelMap[value] is missing, so clickEventHandler does not call setDataMask. That matches the existing context-menu guard that already no-ops when labelMap[e.name] is absent.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A (behavior fix; no UI change). See the recording on #42340 for the previous incorrect behavior.

TESTING INSTRUCTIONS

  1. Create a dashboard with:
    • An ECharts Pie chart (groupby + metric), with Show Total enabled (and optionally Threshold for Other)
    • At least one other chart on the same / compatible dataset
  2. Enable dashboard cross-filtering
  3. Click the pie Total text and/or the Other slice
  4. Confirm other charts are not filtered / do not error
  5. Click a normal pie sector and confirm cross-filtering still works

ADDITIONAL INFORMATION

  • Has associated issue: #42340
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@dosubot dosubot Bot added dashboard:cross-filters Related to the Dashboard cross filters viz:charts:echarts Related to Echarts labels Jul 29, 2026
@bito-code-review

bito-code-review Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #0e7c33

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 252ddec..252ddec
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/eventHandlers.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/eventHandlers.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. Returning early when labelMap[value] is missing prevents the deselection logic from executing, which means existing synthetic filters (like 'Other') cannot be cleared by clicking the chart slice.

To resolve this, you should only return early if the value is not currently selected. If the value is already selected, it must proceed to the deselection logic to allow the filter to be cleared.

Proposed Fix

    const selected = Object.values(selectedValues);
    if (!labelMap[value] && !selected.includes(value)) {
      return undefined;
    }

This change ensures that unknown values are only ignored if they are not part of the current selection, allowing selected unknown values to be processed for deselection.

superset-frontend/plugins/plugin-chart-echarts/src/utils/eventHandlers.ts

const selected = Object.values(selectedValues);
    if (!labelMap[value] && !selected.includes(value)) {
      return undefined;
    }

@codecov

codecov Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.70%. Comparing base (a188e94) to head (8273cd3).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #42559   +/-   ##
=======================================
  Coverage   66.69%   66.70%           
=======================================
  Files        2872     2872           
  Lines      163452   163454    +2     
  Branches    37725    37726    +1     
=======================================
+ Hits       109022   109024    +2     
  Misses      52302    52302           
  Partials     2128     2128           
Flag Coverage Δ
javascript 73.76% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas
rusackas requested review from kgabryje and rusackas July 29, 2026 20:31
@rusackas

rusackas commented Aug 4, 2026

Copy link
Copy Markdown
Member

One thing before I approve. Codeant's thread here is still open: the early return also blocks deselecting an already-selected Other/unknown value, not just new invalid ones, since it returns before ever checking selected.includes(value). Bito's suggested tweak, only short-circuit when the value isn't already selected, seems like the safer fix and keeps the existing "clear by clicking again" behavior intact. @chkang-idk2 mind adding that check? Or... holler if you want me to push some changes here to get it across the finish line.

@pull-request-size pull-request-size Bot added size/M and removed size/S labels Aug 5, 2026
@netlify

netlify Bot commented Aug 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 8273cd3
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a7e7066ad58b00008f3f468
😎 Deploy Preview https://deploy-preview-42559--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

bito-code-review Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #414ad3

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 252ddec..558f800
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/eventHandlers.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/eventHandlers.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

chkang83 and others added 2 commits August 14, 2026 01:32
…pache#42340)

Return undefined when the clicked series is absent from labelMap
(e.g. Pie "Other") so an invalid cross-filter is not applied.
Add a regression test for this case.

Co-authored-by: Cursor <[email protected]>
The early return for unknown labelMap entries ran before checking
whether the value was already selected, so a stale/unknown selected
value (e.g. "Other") could never be cleared by clicking it again.
Only short-circuit when the value isn't currently selected.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@chkang83
chkang83 force-pushed the fix/echarts-guard-cross-filter-labelmap branch from 558f800 to 8273cd3 Compare August 14, 2026 01:33
@bito-code-review

bito-code-review Bot commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #2bfe9e

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 3c77faa..8273cd3
    • superset-frontend/plugins/plugin-chart-echarts/src/utils/eventHandlers.ts
    • superset-frontend/plugins/plugin-chart-echarts/test/utils/eventHandlers.test.ts
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gap I flagged was fixed (by my own follow-up commit) and is all covered by tests, CI is green, and I think we can call this good to go. Bad filters and broken charts are no good, so thanks for tackling this. Approving.

@rusackas
rusackas merged commit 81b3e85 into apache:master Aug 28, 2026
78 checks passed
rusackas added a commit that referenced this pull request Aug 29, 2026
Co-authored-by: Cursor <[email protected]>
Co-authored-by: rusackas <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard:cross-filters Related to the Dashboard cross filters plugins size/M viz:charts:echarts Related to Echarts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(echarts): cross-filter emits invalid filters when pie Total / Other / empty name is clicked

2 participants