yousoph commented on code in PR #41637:
URL: https://github.com/apache/superset/pull/41637#discussion_r3555489741


##########
superset-frontend/src/explore/components/controls/ContourControl/index.tsx:
##########
@@ -88,12 +89,9 @@ const ContourControl = ({ onChange, ...props }: 
ContourControlProps) => {
   };
 
   const onShiftContour = (hoverIndex: number, dragIndex: number) => {
-    const newContours = [...contours];
-    [newContours[hoverIndex], newContours[dragIndex]] = [
-      newContours[dragIndex],
-      newContours[hoverIndex],
-    ];
-    setContours(newContours);
+    // @dnd-kit reports the final indices at drag-end, so reorder with a full
+    // arrayMove rather than an adjacent swap to support non-adjacent drags.
+    setContours(arrayMove(contours, dragIndex, hoverIndex));

Review Comment:
   Good catch — confirmed real. `arrayMove` isn't symmetric, so 
`arrayMove(contours, dragIndex, hoverIndex)` with the reversed param names 
moved the wrong contour on non-adjacent drags (adjacent ones happened to work). 
Fixed in `12064b7081` by renaming the params to `(dragIndex, hoverIndex)` so 
the call is `arrayMove(from, to)`, matching the other DnD controls.



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