codeant-ai-for-open-source[bot] commented on code in PR #42559:
URL: https://github.com/apache/superset/pull/42559#discussion_r3672190021


##########
superset-frontend/plugins/plugin-chart-echarts/src/utils/eventHandlers.ts:
##########
@@ -46,6 +46,9 @@ const getCrossFilterDataMask =
     labelMap: Record<string, string[]>,
   ) =>
   (value: string) => {
+    if (!labelMap[value]) {
+      return undefined;
+    }

Review Comment:
   **Suggestion:** Returning before examining `selectedValues` makes an unknown 
value impossible to deselect. `selectedValues` can still contain a synthetic 
value such as `Other` from an earlier cross-filter state or another dashboard 
interaction, and clicking it then leaves that stale selection active because 
`setDataMask` is never called. Only ignore unknown values when they are not 
currently selected; selected unknown values still need to follow the 
deselection path and emit the remaining or cleared filter state. [stale 
reference]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Synthetic-value filters can remain active after clicking selected Other.
   - ❌ Users cannot clear stale Pie cross-filters through the chart.
   - ⚠️ Dashboard results remain filtered until manually cleared elsewhere.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Configure a Pie chart with a threshold for Other, following the flow in
   
`superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts:6-47`,
 which
   adds an `Other` datum to `transformedData` but does not add `Other` to 
`labelMap` at
   
`superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts:51-62`.
   
   2. Allow the Pie chart to receive a cross-filter state containing `Other`, 
such as a
   previously emitted synthetic-value filter or a compatible dashboard chart 
interaction;
   
`superset-frontend/plugins/plugin-chart-echarts/src/Pie/transformProps.ts:101-112`
 retains
   every incoming `filterState.selectedValues` entry in the `selectedValues` 
record,
   including values whose label-map entry is absent.
   
   3. Render the chart through
   
`superset-frontend/plugins/plugin-chart-echarts/src/Pie/EchartsPie.tsx:24-36`;
   `allEventHandlers` at
   
`superset-frontend/plugins/plugin-chart-echarts/src/utils/eventHandlers.ts:158-185`
 passes
   that selected-value record into `getCrossFilterDataMask`.
   
   4. Click the already-selected `Other` slice. The new guard at
   
`superset-frontend/plugins/plugin-chart-echarts/src/utils/eventHandlers.ts:49-51`
 returns
   before the deselection logic at lines 52-56, so `clickEventHandler` at lines 
108-111 never
   calls `setDataMask`; the existing `Other` filter remains active instead of 
being cleared.
   The current test at
   
`superset-frontend/plugins/plugin-chart-echarts/test/utils/eventHandlers.test.ts:184-200`
   covers only an unselected unknown name and does not cover this deselection 
case.
   ```
   </details>
   
   [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3ec0db08b7e34889938466439dc8cfe2&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=3ec0db08b7e34889938466439dc8cfe2&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 a comment left during a code review.
   
   **Path:** 
superset-frontend/plugins/plugin-chart-echarts/src/utils/eventHandlers.ts
   **Line:** 49:51
   **Comment:**
        *Stale Reference: Returning before examining `selectedValues` makes an 
unknown value impossible to deselect. `selectedValues` can still contain a 
synthetic value such as `Other` from an earlier cross-filter state or another 
dashboard interaction, and clicking it then leaves that stale selection active 
because `setDataMask` is never called. Only ignore unknown values when they are 
not currently selected; selected unknown values still need to follow the 
deselection path and emit the remaining or cleared filter state.
   
   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.
   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>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42559&comment_hash=a03d951ada955bb369295d4b51f6761457d23b8366f365f3793c51ad5a9e0376&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42559&comment_hash=a03d951ada955bb369295d4b51f6761457d23b8366f365f3793c51ad5a9e0376&reaction=dislike'>👎</a>



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