Bug description

When creating a map chart with the DeckGL Scatter type, using the legend to toggle layer visibility works as expected. However, when I hold the Control (Ctrl) key and click on a legend item (to enable/disable a layer), a new browser tab opens each time. This is not the expected behavior—only the layer visibility should toggle.

Reproduction steps

Go to Charts and create a new chart using DeckGL Scatter.

Make sure the dataset includes multiple categories, so the legend is visible.

In the legend, hold the Ctrl key and click on any legend item to toggle visibility.

Notice that a new browser tab opens each time you Ctrl+Click a legend item.

https://github.com/user-attachments/assets/2b945c95-a73d-4477-a666-66f074d698c8

Screenshots/recordings

No response

Superset version

4.1.2

Python version

3.11

Node version

I don't know

Browser

Chrome

Additional context

I am using Microsoft Edge browser on Debian 12 Version 138.0.3351.55 (Official build) (64-bit)

Checklist

  • [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
  • [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
  • [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.

Comment From: dosubot[bot]

This is a valid bug caused by how the legend items are implemented in the DeckGL Scatter Map. The legend entries are rendered as anchor tags (<a href="#">) without calling event.preventDefault() in their onClick handler. As a result, when you Ctrl+Click (or Cmd+Click) a legend item, the browser opens a new tab, which is the default behavior for anchor tags with an href attribute when a modifier key is pressed. This happens regardless of browser or OS, so it's not specific to Edge or Debian see code.

There is no existing fix for this in recent Superset releases or PRs. As a workaround, avoid using Ctrl+Click on legend items. For a code fix, you (or your team) can update the onClick handler in Legend.tsx to accept the event argument and call event.preventDefault() before toggling the category. For example:

<a
  href="#"
  role="button"
  onClick={e => {
    e.preventDefault();
    toggleCategory(k);
  }}
  ...
>

This will prevent the browser from opening a new tab and ensure only the legend visibility toggles. If you’re not able to patch this locally, keep an eye on future Superset releases for a fix.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

Comment From: Prasad-JB

Thanks for the detailed explanation. I’d like to work on this. The fix looks straightforward — updating the legend’s click handler in Legend.tsx to call event.preventDefault() so Ctrl/Cmd+Click doesn’t open a new tab. I’ll open a PR with the change.

Comment From: Navid61

Thank you so much! However, there is another issue. When we click on a layer name in the legend to turn it off or on, the layer remains visible on the map even after being toggled off.

Comment From: msyavuz

It's probably an easy enough change but we need to understand if there is a use case where ctrl+click opening a new tab is wanted since thats the default and expected behaviour for links everywhere

Comment From: Prasad-JB

I tested this too and can confirm the same problem .Preventing the default link action and fixing the toggle so, layers actually hide/show should solve it . Looking forward to the PR.