codeant-ai-for-open-source[bot] commented on code in PR #41111:
URL: https://github.com/apache/superset/pull/41111#discussion_r3419030081
##########
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx:
##########
@@ -201,6 +202,11 @@ function Echart(
chartRef.current?.on(name, handler);
});
+ (queryEventHandlers || []).forEach(({ name, query, handler }) => {
+ chartRef.current?.off(name, handler);
+ chartRef.current?.on(name, query, handler);
+ });
Review Comment:
**🟠Architect Review — HIGH**
Query-based listeners are removed with `off(name, handler)` using the
current handler reference, so when handlers are recreated on re-render (e.g. as
`selectedValues`/cross-filter state changes), previous handlers remain
subscribed and x-axis label clicks can trigger cross-filter updates multiple
times.
**Suggestion:** Make query listener teardown independent of the current
handler instance by clearing all query-based listeners for a given event before
re-binding, or by keeping a stable handler reference and explicitly
unregistering the previous one when dependencies change; also ensure that when
the handlers array becomes empty, any existing query listeners are removed.
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=94920be337f24a8389078ec587f2594e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=94920be337f24a8389078ec587f2594e&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is an **Architect / Logical Review** comment left during a code review.
These reviews are first-class, important findings — not optional suggestions.
Do NOT dismiss this as a 'big architectural change' just because the title says
architect review; most of these can be resolved with a small, localized fix
once the intent is understood.
**Path:**
superset-frontend/plugins/plugin-chart-echarts/src/components/Echart.tsx
**Line:** 205:208
**Comment:**
*HIGH: Query-based listeners are removed with `off(name, handler)`
using the current handler reference, so when handlers are recreated on
re-render (e.g. as `selectedValues`/cross-filter state changes), previous
handlers remain subscribed and x-axis label clicks can trigger cross-filter
updates multiple times.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
If a suggested approach is provided above, use it as the authoritative
instruction. If no explicit code suggestion is given, you MUST still draft and
apply your own minimal, localized fix — do not punt back with 'no suggestion
provided, review manually'. Keep the change as small as possible: add a guard
clause, gate on a loading state, reorder an await, wrap in a conditional, etc.
Do not refactor surrounding code or expand scope beyond the finding.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
--
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]