korbit-ai[bot] commented on code in PR #31495:
URL: https://github.com/apache/superset/pull/31495#discussion_r2237733740


##########
superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:
##########
@@ -52,45 +51,47 @@ export default function EchartsSunburst(props: 
SunburstTransformedProps) {
   const getCrossFilterDataMask = useCallback(
     (treePathInfo: TreePathInfo[]) => {
       const treePath = extractTreePathInfo(treePathInfo);
-      const name = treePath.join(',');
-      const selected = Object.values(selectedValues);
-      let values: string[];
-      if (selected.includes(name)) {
-        values = selected.filter(v => v !== name);
-      } else {
-        values = [name];
+      const joinedThreePath = treePath.join(',');
+      const value = treePath[treePath.length - 1];
+
+      const isCurrentValueSelected =
+        Object.values(selectedValues).includes(joinedThreePath);
+
+      if (!columns?.length || isCurrentValueSelected) {
+        return {
+          dataMask: {
+            extraFormData: {
+              filters: [],
+            },
+            filterState: {
+              value: null,
+              selectedValues: [],
+            },
+          },
+          isCurrentValueSelected,
+        };
       }
-      const labels = values.map(value => labelMap[value]);
 
       return {
         dataMask: {
           extraFormData: {
-            filters:
-              values.length === 0 || !columns
-                ? []
-                : columns.slice(0, treePath.length).map((col, idx) => {
-                    const val = labels.map(v => v[idx]);
-                    if (val === null || val === undefined)
-                      return {
-                        col,
-                        op: 'IS NULL' as const,
-                      };
-                    return {
-                      col,
-                      op: 'IN' as const,
-                      val: val as (string | number | boolean)[],
-                    };
-                  }),
+            filters: [
+              {
+                col: columns[treePath.length - 1],
+                op: '==' as const,
+                val: value,
+              },
+            ],

Review Comment:
   ### Incomplete hierarchical filtering in Sunburst chart <sub>![category 
Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The filter is only being applied to the last level of the tree path, 
ignoring parent levels. This doesn't maintain the hierarchical relationship in 
the Sunburst chart's filtering.
   
   
   ###### Why this matters
   Users might see incorrect data when filtering because parent-child 
relationships in the hierarchy are not preserved. For example, if there are two 
nodes with the same name at different levels or under different parents, the 
current filter would match both incorrectly.
   
   ###### Suggested change ∙ *Feature Preview*
   Modify the filter generation to include all levels of the hierarchy:
   ```typescript
   filters: treePath.map((path, idx) => ({
       col: columns[idx],
       op: '==' as const,
       val: path,
   })),
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice 
Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/351d6ee9-ec4b-49f4-a70f-df13ab4bdfbb/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/351d6ee9-ec4b-49f4-a70f-df13ab4bdfbb?what_not_true=true)
  [![Not in 
Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/351d6ee9-ec4b-49f4-a70f-df13ab4bdfbb?what_out_of_scope=true)
 [![Not in coding 
standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/351d6ee9-ec4b-49f4-a70f-df13ab4bdfbb?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/351d6ee9-ec4b-49f4-a70f-df13ab4bdfbb)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:5b1979b6-3a8b-433e-b4a9-5cf525d87b76 -->
   
   
   [](5b1979b6-3a8b-433e-b4a9-5cf525d87b76)



##########
superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/EchartsSunburst.tsx:
##########
@@ -52,45 +51,47 @@
   const getCrossFilterDataMask = useCallback(
     (treePathInfo: TreePathInfo[]) => {
       const treePath = extractTreePathInfo(treePathInfo);
-      const name = treePath.join(',');
-      const selected = Object.values(selectedValues);
-      let values: string[];
-      if (selected.includes(name)) {
-        values = selected.filter(v => v !== name);
-      } else {
-        values = [name];
+      const joinedThreePath = treePath.join(',');

Review Comment:
   ### Typo in Variable Name <sub>![category 
Readability](https://img.shields.io/badge/Readability-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   Variable name contains a typo ('Three' instead of 'Tree') which could cause 
confusion.
   
   
   ###### Why this matters
   Typos in variable names can mislead developers about the variable's purpose 
and make code harder to maintain.
   
   ###### Suggested change ∙ *Feature Preview*
   ```typescript
   const joinedTreePath = treePath.join(',');
   ```
   
   
   ###### Provide feedback to improve future suggestions
   [![Nice 
Catch](https://img.shields.io/badge/👍%20Nice%20Catch-71BC78)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f0d9d452-1bc6-4b14-a95d-29b4edc88c10/upvote)
 
[![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f0d9d452-1bc6-4b14-a95d-29b4edc88c10?what_not_true=true)
  [![Not in 
Scope](https://img.shields.io/badge/👎%20Out%20of%20PR%20scope-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f0d9d452-1bc6-4b14-a95d-29b4edc88c10?what_out_of_scope=true)
 [![Not in coding 
standard](https://img.shields.io/badge/👎%20Not%20in%20our%20standards-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f0d9d452-1bc6-4b14-a95d-29b4edc88c10?what_not_in_standard=true)
 
[![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/f0d9d452-1bc6-4b14-a95d-29b4edc88c10)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:9b95bcac-19a4-4885-8640-274ab34cda28 -->
   
   
   [](9b95bcac-19a4-4885-8640-274ab34cda28)



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