bito-code-review[bot] commented on code in PR #38680:
URL: https://github.com/apache/superset/pull/38680#discussion_r2988651402


##########
superset-frontend/plugins/plugin-chart-echarts/src/Timeseries/transformProps.ts:
##########
@@ -987,8 +943,18 @@ export default function transformProps(
       scrollDataIndex: legendIndex || 0,
       data:
         colorByPrimaryAxis && groupBy.length === 0
-          ? colorByPrimaryAxisLegendData
-          : sortedLegendData,
+          ? // When colorByPrimaryAxis, configure legend items with roundRect 
icons
+            legendData.map(name => ({
+              name,
+              icon: 'roundRect',
+            }))
+          : // Otherwise use normal legend data
+            legendData.sort((a: string, b: string) => {
+              if (!legendSort) return 0;
+              return legendSort === 'asc'
+                ? a.localeCompare(b)
+                : b.localeCompare(a);
+            }),

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Array mutation changes return value</b></div>
   <div id="fix">
   
   Calling sort() directly on legendData mutates the array in place, which 
changes the order of the legendData returned in the transformed props. This 
alters the API behavior compared to the original code that used a sorted copy. 
Use a spread copy to maintain the original array's order.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
               [...legendData].sort((a: string, b: string) => {
                 if (!legendSort) return 0;
                 return legendSort === 'asc'
                   ? a.localeCompare(b)
                   : b.localeCompare(a);
               }),
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #420fd9</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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