You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "CoderSxy (via GitHub)" <gi...@apache.org> on 2025/10/28 10:34:27 UTC

[PR] fix: drag a metric very quickly,the order is chaotic. [superset]

CoderSxy opened a new pull request, #35867:
URL: https://github.com/apache/superset/pull/35867

   <!---
   Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
   Example:
   fix(dashboard): load charts correctly
   -->
   
   ### SUMMARY
   <!--- Describe the change below, including rationale and design decisions -->
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   <!--- Skip this if not applicable -->
   
   ### TESTING INSTRUCTIONS
   <!--- Required! What steps can be taken to manually verify the changes? -->
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:#33951
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-3544210242

   Otherwise curious if you have any comments on the AI bot feedback. 


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #35867:
URL: https://github.com/apache/superset/pull/35867#discussion_r3488507717


##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/utils/optionSelector.ts:
##########
@@ -89,6 +89,11 @@ export class OptionSelector {
     [this.values[a], this.values[b]] = [this.values[b], this.values[a]];
   }
 
+  reorder(from: number, to: number) {
+    const [moved] = this.values.splice(from, 1);
+    this.values.splice(to, 0, moved);
+  }

Review Comment:
   **Suggestion:** The new reorder helper does not validate index bounds. If drag metadata is stale or out of range, `splice` returns no element and `undefined` gets inserted into the values list, which later causes runtime failures when the UI treats each item as a column object. Add an early guard for same-index and out-of-range `from`/`to` values before mutating the array. [null pointer]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Explore Dnd column selector can crash on invalid indices.
   - ⚠️ Drag-and-drop column reordering becomes unreliable under race conditions.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. In the Explore view, perform a drag-and-drop reorder within the Dnd column selector
   control, which uses `DndColumnSelect` at
   `superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndColumnSelect.tsx:42-116`.
   `DndColumnSelect` registers `onShiftOptions` that calls `optionSelector.reorder(dragIndex,
   hoverIndex)` at lines 109-112.
   
   2. The drag operation is handled by `ExploreDndContextProvider` in
   `superset-frontend/src/explore/components/ExploreContainer/ExploreDndContext.tsx`. On drag
   end, `handleDragEnd` (lines 12-22, 190-22 in the same file) calls `resolveDragEnd(active,
   over)` (lines 112-153), which reads `active.data.current.dragIndex` and
   `over.data.current.dragIndex` and, if both are numbers and types match, invokes the
   reorder callback at line 135.
   
   3. The sortable items for the column selector are `OptionWrapper` instances
   (`superset-frontend/src/explore/components/controls/DndColumnSelectControl/OptionWrapper.tsx:41-82`),
   which set `data: { type, dragIndex: index, onShiftOptions }` into `useSortable`. If, due
   to stale drag metadata or a programming error, either `activeData.dragIndex` or
   `overData.dragIndex` becomes out of range with respect to `optionSelector.values` (for
   example, simulate this by calling `resolveDragEnd` in a unit test with `dragIndex` equal
   to 10 while `optionSelector.values.length` is 3), `resolveDragEnd` still calls
   `onShiftOptions(dragIndex, hoverIndex)` with these invalid indices at line 135.
   
   4. `onShiftOptions` in `DndColumnSelect.tsx` (lines 109-113) forwards the invalid indices
   to `OptionSelector.reorder` in
   `superset-frontend/src/explore/components/controls/DndColumnSelectControl/utils/optionSelector.ts:92-95`.
   There, `this.values.splice(from, 1)` returns an empty array, so `moved` becomes
   `undefined`, and `this.values.splice(to, 0, moved)` inserts `undefined` into
   `optionSelector.values`. On the next render, `valuesRenderer` (lines 117-158 in
   `DndColumnSelect.tsx`) iterates `optionSelector.values` and passes each `column` into
   `OptionWrapper` and ultimately `StyledColumnOption` (`OptionWrapper.tsx:116-124`), which
   casts `column` as `ColumnMeta` and expects a valid object. When `column` is `undefined`,
   downstream chart-control components attempt to access properties on `undefined`, causing a
   runtime TypeError and breaking the column selector UI.
   ```
   </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=13af4a0222ac4a039f55957ac73b6b62&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=13af4a0222ac4a039f55957ac73b6b62&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/src/explore/components/controls/DndColumnSelectControl/utils/optionSelector.ts
   **Line:** 92:95
   **Comment:**
   	*Null Pointer: The new reorder helper does not validate index bounds. If drag metadata is stale or out of range, `splice` returns no element and `undefined` gets inserted into the values list, which later causes runtime failures when the UI treats each item as a column object. Add an early guard for same-index and out-of-range `from`/`to` values before mutating the array.
   
   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%2F35867&comment_hash=ab11dfbe41ae4478a416a86c572f00d08ae647df4de59e2d4c07d83d681a0ab1&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F35867&comment_hash=ab11dfbe41ae4478a416a86c572f00d08ae647df4de59e2d4c07d83d681a0ab1&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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #35867:
URL: https://github.com/apache/superset/pull/35867#discussion_r2468975453


##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/utils/optionSelector.ts:
##########
@@ -89,6 +89,11 @@ export class OptionSelector {
     [this.values[a], this.values[b]] = [this.values[b], this.values[a]];
   }
 
+  reorder(a: number, b: number) {
+    const [moved] = this.values.splice(a, 1);
+    this.values.splice(b, 0, moved);
+  }

Review Comment:
   ### Missing bounds validation in reorder method <sub>![category Performance](https://img.shields.io/badge/Performance-4f46e5)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The reorder method lacks bounds checking for array indices, which can cause runtime errors or undefined behavior when invalid indices are passed.
   
   
   ###### Why this matters
   Without bounds validation, passing out-of-range indices could lead to unexpected splice operations, potential runtime errors, or silent failures that corrupt the array state.
   
   ###### Suggested change ∙ *Feature Preview*
   Add bounds checking before performing splice operations:
   ```typescript
   reorder(a: number, b: number) {
     if (a < 0 || a >= this.values.length || b < 0 || b > this.values.length) {
       return;
     }
     const [moved] = this.values.splice(a, 1);
     this.values.splice(b, 0, moved);
   }
   ```
   
   
   ###### 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/58ee55f4-c091-468b-898f-1dd5cad9feac/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/58ee55f4-c091-468b-898f-1dd5cad9feac?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/58ee55f4-c091-468b-898f-1dd5cad9feac?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/58ee55f4-c091-468b-898f-1dd5cad9feac?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/58ee55f4-c091-468b-898f-1dd5cad9feac)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:9a1b4e95-df21-4682-9670-4acf1e650a7b -->
   
   
   [](9a1b4e95-df21-4682-9670-4acf1e650a7b)



##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndColumnSelect.tsx:
##########
@@ -96,7 +96,7 @@ function DndColumnSelect(props: DndColumnSelectProps) {
 
   const onShiftOptions = useCallback(
     (dragIndex: number, hoverIndex: number) => {
-      optionSelector.swap(dragIndex, hoverIndex);
+      optionSelector.reorder(dragIndex, hoverIndex);

Review Comment:
   ### Unverified reorder method implementation <sub>![category Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The code calls `reorder` method on `optionSelector` but the implementation and existence of this method cannot be verified from the provided code.
   
   
   ###### Why this matters
   If the `reorder` method doesn't exist, has incorrect signature, or doesn't implement proper bounds checking and immutable reordering as intended, the drag-and-drop functionality will fail at runtime or continue to exhibit the chaotic ordering behavior the change aims to fix.
   
   ###### Suggested change ∙ *Feature Preview*
   Verify that the `OptionSelector` class in `src/explore/components/controls/DndColumnSelectControl/utils` has a `reorder(dragIndex: number, hoverIndex: number): void` method that implements bounds-checked, immutable reordering as described in the developer intent.
   
   
   ###### 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/31474633-71d6-463a-9052-56910247e6a2/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/31474633-71d6-463a-9052-56910247e6a2?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/31474633-71d6-463a-9052-56910247e6a2?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/31474633-71d6-463a-9052-56910247e6a2?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/31474633-71d6-463a-9052-56910247e6a2)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:7df30bdc-8761-4c4e-aa7b-7ceda2a51650 -->
   
   
   [](7df30bdc-8761-4c4e-aa7b-7ceda2a51650)



##########
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl/index.jsx:
##########
@@ -285,14 +285,20 @@ class AdhocFilterControl extends Component {
   }
 
   moveLabel(dragIndex, hoverIndex) {
-    const { values } = this.state;
 
-    const newValues = [...values];
-    [newValues[hoverIndex], newValues[dragIndex]] = [
-      newValues[dragIndex],
-      newValues[hoverIndex],
-    ];
-    this.setState({ values: newValues });
+    const { values } = this.state;
+    if (
+      dragIndex === hoverIndex ||
+      dragIndex < 0 ||
+      hoverIndex < 0 ||
+      dragIndex >= values.length ||
+      hoverIndex >= values.length
+    ) {
+      return;
+    }
+    const [moved] = this.values.splice(dragIndex, 1);
+    this.values.splice(hoverIndex, 0, moved);

Review Comment:
   ### Undefined property reference in moveLabel <sub>![category Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The code references `this.values` which is undefined, instead of `this.state.values`.
   
   
   ###### Why this matters
   This will cause a runtime error when attempting to reorder items via drag and drop, as `this.values` does not exist on the component instance.
   
   ###### Suggested change ∙ *Feature Preview*
   Replace `this.values` with `values` (the destructured state variable) or create a proper copy:
   
   ```javascript
   const newValues = [...values];
   const [moved] = newValues.splice(dragIndex, 1);
   newValues.splice(hoverIndex, 0, moved);
   this.setState({ values: newValues });
   this.props.onChange(newValues);
   ```
   
   
   ###### 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/6998f229-d7ab-4410-955d-da0214d1c4f5/upvote) [![Incorrect](https://img.shields.io/badge/👎%20Incorrect-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/6998f229-d7ab-4410-955d-da0214d1c4f5?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/6998f229-d7ab-4410-955d-da0214d1c4f5?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/6998f229-d7ab-4410-955d-da0214d1c4f5?what_not_in_standard=true) [![Other](https://img.shields.io/badge/👎%20Other-white)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/6998f229-d7ab-4410-955d-da0214d1c4f5)
   </details>
   
   <sub>
   
   💬 Looking for more details? Reply to this comment to chat with Korbit.
   </sub>
   
   <!--- korbi internal id:3c3c0967-6023-4e42-ba20-56bb17ed9959 -->
   
   
   [](3c3c0967-6023-4e42-ba20-56bb17ed9959)



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-4827324519

   Picked this up to get it across the line, @CoderSxy, thanks for diagnosing a genuinely annoying bug! The swap-vs-reorder root cause was spot on. I rebased on current master and reworked it a bit:
   
   - The swap → splice-reorder fix is applied across all the controls (`DndMetricSelect`, `DndFilterSelect`, `DndColumnSelect` via a new `OptionSelector.reorder`, and `AdhocFilterControl`). That last one had been converted to a TS function component on master since you opened this, so I ported the fix to the new `setValues(prev => ...)` form (the old `.jsx` patch referenced `this.values`, which no longer exists).
   - Dropped the `onChange(newValue)` that had been added inside `DndMetricSelect.moveLabel`, since `handleDropLabel` already persists on drop, so firing it on every hover would have re-queried mid-drag.
   - Added an `OptionSelector.reorder` unit test pinning the regression (moving an item across several positions must preserve the order of the rest, which a swap would scramble).
   
   Frontend pre-commit and the affected component tests pass locally. Running CI now 🤞


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "CoderSxy (via GitHub)" <gi...@apache.org>.
CoderSxy commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-3459387761

   Dragging a Metric will affect the order of other metrics


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #35867:
URL: https://github.com/apache/superset/pull/35867#discussion_r3651982101


##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/utils/optionSelector.ts:
##########
@@ -89,6 +89,11 @@ export class OptionSelector {
     [this.values[a], this.values[b]] = [this.values[b], this.values[a]];
   }
 
+  reorder(a: number, b: number) {
+    const [moved] = this.values.splice(a, 1);
+    this.values.splice(b, 0, moved);
+  }

Review Comment:
   Good catch, fixed. `reorder` now bails on out-of-range or no-op indices before it splices.



##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/utils/optionSelector.ts:
##########
@@ -89,6 +89,11 @@ export class OptionSelector {
     [this.values[a], this.values[b]] = [this.values[b], this.values[a]];
   }
 
+  reorder(from: number, to: number) {
+    const [moved] = this.values.splice(from, 1);
+    this.values.splice(to, 0, moved);
+  }

Review Comment:
   Same fix as Korbit's note on the same method, `reorder` now guards out-of-range and no-op indices before splicing.



##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndColumnSelect.tsx:
##########
@@ -96,7 +96,7 @@ function DndColumnSelect(props: DndColumnSelectProps) {
 
   const onShiftOptions = useCallback(
     (dragIndex: number, hoverIndex: number) => {

Review Comment:
   Went with the guard living inside `OptionSelector.reorder` itself instead of duplicating it at every call site, same effect but one place to keep in sync.



##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.tsx:
##########
@@ -252,12 +252,19 @@ const DndFilterSelect = (props: DndFilterSelectProps) => {
 
   const onShiftOptions = useCallback(
     (dragIndex: number, hoverIndex: number) => {
-      const newValues = [...values];
-      [newValues[hoverIndex], newValues[dragIndex]] = [
-        newValues[dragIndex],
-        newValues[hoverIndex],
-      ];
-      setValues(newValues);
+      if (
+        dragIndex === hoverIndex ||
+        dragIndex < 0 ||
+        hoverIndex < 0 ||
+        dragIndex >= values.length ||
+        hoverIndex >= values.length
+      ) {
+        return;
+      }
+      const newValue = [...values];
+      const [moved] = newValue.splice(dragIndex, 1);
+      newValue.splice(hoverIndex, 0, moved);
+      setValues(newValue);
     },
     [values],

Review Comment:
   Good catch, fixed. `onShiftOptions` now calls `onChange` after committing the reordered array.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-3455795082

   <details open>
     <summary><strong>Interaction Diagram by <a href="https://bito.ai#sequence_diagram">Bito</a></strong></summary>
   
   ```mermaid
   sequenceDiagram
   participant UI as UI Layer<br/>OptionWrapper
   participant DndCol as DndColumnSelect<br/>🔄 Updated | ●●○ Medium
   participant OptionSel as OptionSelector<br/>🔄 Updated | ●●● High
   participant State as Component State
   participant Parent as Parent Component
   Note over UI, Parent: Drag-drop reorder flow with validation
   UI->>DndCol: onShiftOptions(dragIdx, hoverIdx)
   DndCol->>OptionSel: reorder(dragIdx, hoverIdx)
   OptionSel->>State: Update values array
   State-->>DndCol: Updated array
   DndCol->>Parent: onChange(newValues)
   Parent-->>UI: Reflect reordered state
   ```
   Critical path: UI Layer-&gt;DndColumnSelect-&gt;OptionSelector-&gt;Component State-&gt;Parent Component
   
   
   > **Note:** The diff refactors drag-drop reordering across multiple components by replacing simple swap operations with splice-based reordering and adding boundary validation. This prevents index out-of-bounds errors and improves array manipulation reliability. Upstream callers (OptionWrapper, UI handlers) remain stable; downstream state updates and parent notifications are enhanced.
   
   </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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-4827441993

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/35867?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `35.48387%` with `20 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 64.56%. Comparing base ([`6eb5110`](https://app.codecov.io/gh/apache/superset/commit/6eb51105d0116fa13beb51455a08176b33e03ad5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`96f3ccf`](https://app.codecov.io/gh/apache/superset/commit/96f3ccf9eed35a576e6d9cb2603ec03768bd97d2?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/35867?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...ontrols/DndColumnSelectControl/DndFilterSelect.tsx](https://app.codecov.io/gh/apache/superset/pull/35867?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2Fexplore%2Fcomponents%2Fcontrols%2FDndColumnSelectControl%2FDndFilterSelect.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9EbmRDb2x1bW5TZWxlY3RDb250cm9sL0RuZEZpbHRlclNlbGVjdC50c3g=) | 0.00% | [9 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/35867?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...ontrols/FilterControl/AdhocFilterControl/index.tsx](https://app.codecov.io/gh/apache/superset/pull/35867?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2Fexplore%2Fcomponents%2Fcontrols%2FFilterControl%2FAdhocFilterControl%2Findex.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9GaWx0ZXJDb250cm9sL0FkaG9jRmlsdGVyQ29udHJvbC9pbmRleC50c3g=) | 0.00% | [9 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/35867?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...ontrols/DndColumnSelectControl/DndColumnSelect.tsx](https://app.codecov.io/gh/apache/superset/pull/35867?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2Fexplore%2Fcomponents%2Fcontrols%2FDndColumnSelectControl%2FDndColumnSelect.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9EbmRDb2x1bW5TZWxlY3RDb250cm9sL0RuZENvbHVtblNlbGVjdC50c3g=) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/35867?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...ontrols/DndColumnSelectControl/DndMetricSelect.tsx](https://app.codecov.io/gh/apache/superset/pull/35867?src=pr&el=tree&filepath=superset-frontend%2Fsrc%2Fexplore%2Fcomponents%2Fcontrols%2FDndColumnSelectControl%2FDndMetricSelect.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQtZnJvbnRlbmQvc3JjL2V4cGxvcmUvY29tcG9uZW50cy9jb250cm9scy9EbmRDb2x1bW5TZWxlY3RDb250cm9sL0RuZE1ldHJpY1NlbGVjdC50c3g=) | 88.88% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/35867?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #35867      +/-   ##
   ==========================================
   - Coverage   64.57%   64.56%   -0.01%     
   ==========================================
     Files        2664     2664              
     Lines      146355   146382      +27     
     Branches    33842    33860      +18     
   ==========================================
   + Hits        94504    94515      +11     
   - Misses      50135    50151      +16     
     Partials     1716     1716              
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/35867/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [javascript](https://app.codecov.io/gh/apache/superset/pull/35867/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `69.03% <35.48%> (-0.01%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/35867?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #35867:
URL: https://github.com/apache/superset/pull/35867#discussion_r2470450485


##########
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterControl/index.jsx:
##########
@@ -285,14 +285,20 @@ class AdhocFilterControl extends Component {
   }
 
   moveLabel(dragIndex, hoverIndex) {
-    const { values } = this.state;
 
-    const newValues = [...values];
-    [newValues[hoverIndex], newValues[dragIndex]] = [
-      newValues[dragIndex],
-      newValues[hoverIndex],
-    ];
-    this.setState({ values: newValues });
+    const { values } = this.state;
+    if (
+      dragIndex === hoverIndex ||
+      dragIndex < 0 ||
+      hoverIndex < 0 ||
+      dragIndex >= values.length ||
+      hoverIndex >= values.length
+    ) {
+      return;
+    }
+    const [moved] = this.values.splice(dragIndex, 1);
+    this.values.splice(hoverIndex, 0, moved);
+    this.props.onChange(this.state.values);

Review Comment:
   Bug: `this.values` is undefined. The code should use the local `values` variable that was extracted from state on line 289. Additionally, the state needs to be updated via `setState` before calling `onChange`. 
   
   Suggested fix:
   ```javascript
   const newValues = [...values];
   const [moved] = newValues.splice(dragIndex, 1);
   newValues.splice(hoverIndex, 0, moved);
   this.setState({ values: newValues }, () => {
     this.props.onChange(newValues);
   });
   ```
   ```suggestion
       const newValues = [...values];
       const [moved] = newValues.splice(dragIndex, 1);
       newValues.splice(hoverIndex, 0, moved);
       this.setState({ values: newValues }, () => {
         this.props.onChange(newValues);
       });
   ```



##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndColumnSelect.tsx:
##########
@@ -96,7 +96,7 @@ function DndColumnSelect(props: DndColumnSelectProps) {
 
   const onShiftOptions = useCallback(
     (dragIndex: number, hoverIndex: number) => {

Review Comment:
   The `reorder` method is called without bounds validation, unlike the similar implementations in `DndMetricSelect.tsx` and `DndFilterSelect.tsx`. Consider adding bounds checking before calling `reorder` for consistency and safety:
   
   ```typescript
   if (
     dragIndex === hoverIndex ||
     dragIndex < 0 ||
     hoverIndex < 0 ||
     dragIndex >= optionSelector.values.length ||
     hoverIndex >= optionSelector.values.length
   ) {
     return;
   }
   ```
   ```suggestion
       (dragIndex: number, hoverIndex: number) => {
         if (
           dragIndex === hoverIndex ||
           dragIndex < 0 ||
           hoverIndex < 0 ||
           dragIndex >= optionSelector.values.length ||
           hoverIndex >= optionSelector.values.length
         ) {
           return;
         }
   ```



##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.tsx:
##########
@@ -252,12 +252,19 @@ const DndFilterSelect = (props: DndFilterSelectProps) => {
 
   const onShiftOptions = useCallback(
     (dragIndex: number, hoverIndex: number) => {
-      const newValues = [...values];
-      [newValues[hoverIndex], newValues[dragIndex]] = [
-        newValues[dragIndex],
-        newValues[hoverIndex],
-      ];
-      setValues(newValues);
+      if (
+        dragIndex === hoverIndex ||
+        dragIndex < 0 ||
+        hoverIndex < 0 ||
+        dragIndex >= values.length ||
+        hoverIndex >= values.length
+      ) {
+        return;
+      }
+      const newValue = [...values];
+      const [moved] = newValue.splice(dragIndex, 1);
+      newValue.splice(hoverIndex, 0, moved);
+      setValues(newValue);
     },
     [values],

Review Comment:
   Missing `onChange` call after reordering. Unlike `DndMetricSelect.tsx` which calls both `setValue` and `onChange` in its `moveLabel` function, this implementation only calls `setValues` without propagating the change to the parent component. This means the reordered values won't be persisted.
   
   Suggested fix:
   ```typescript
   const newValue = [...values];
   const [moved] = newValue.splice(dragIndex, 1);
   newValue.splice(hoverIndex, 0, moved);
   setValues(newValue);
   onChange(newValue);  // Add this line
   ```
   ```suggestion
         onChange(newValue);
       },
       [onChange, values],
   ```



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-3544208176

   Thanks for the screenshots. Looks like you need to run `prettier` or all the pre-commit checks. 


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-3457652983

   @CoderSxy do you mind adding a before and after video so we know what's going on?


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-5039548338

   This drifted from `master` again since my last pass, back to conflicting. The splice-based reorder and bounds guards still look right, so it's just a rebase away. @CoderSxy let me know if you're still interested here, otherwise I'll keep meddling with this to try and see it through. 


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-4934963624

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-4353663319

   @CoderSxy — checking in on this one. A few things are blocking it from progressing:
   
   - The branch is conflicting with master and CI is red; a rebase + green CI run is needed.
   - Reviewer bots flagged what look like real bugs that aren't addressed yet:
     - `AdhocFilterControl/index.jsx:301` — `this.values` is undefined here; it should use the destructured `values` and update via `setState` before calling `onChange` (per @copilot-pull-request-reviewer).
     - `DndFilterSelect.tsx:269` — the reorder path calls `setValues` but never `onChange(newValue)`, so the new order isn't propagated to the parent.
     - `DndColumnSelect.tsx:98` / `optionSelector.ts:95` — `reorder` is missing the bounds checks the sibling Dnd components have.
   - The PR description is still the unfilled template; a quick SUMMARY + TESTING INSTRUCTIONS would help reviewers.
   
   Let us know once those are addressed and we'll take another look. If you've moved on, no worries — just give us a heads-up so we can close it out.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-3455766428

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-4827760768

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-4933578113

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 62d6f9d6436433490bad7e6c051955291c17b098 |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a50af2221d0f400081c38e8 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-35867--superset-docs-preview.netlify.app](https://deploy-preview-35867--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTM1ODY3LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ._5GsRjLTtgYie_LUXGUw7vBr6jIO-r2CqsdRM86C12o)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#q1YqKMrPLShRslJS0lFKKkrMS84AstMyK-KLKyqBQimpBTn5lZ4pQEGzRFODxDQjIyPDFIM0EwMDAwvDZGOLVAulWgA) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-35867--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "CoderSxy (via GitHub)" <gi...@apache.org>.
CoderSxy commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-3459333718

   ### Before modification
   ![1029yuan](https://github.com/user-attachments/assets/414dbc80-2288-4279-92b7-7b77092373c2)
   ![1029yuan1](https://github.com/user-attachments/assets/2b380fcd-effc-4777-b2cb-920d293b231a)
   ### After
   ![1029xian](https://github.com/user-attachments/assets/38815e86-5bc1-4241-b6ab-3f929e3eb8ba)
   ![1029xian1](https://github.com/user-attachments/assets/d00370ff-4fac-46a7-8600-608008fe70f3)
   
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-4827851086

   Thanks for the rebase and the splice rework, @CoderSxy - the move-vs-swap logic and the bounds checks look right.
   
   One thing still seems off though: the reordered array doesn't cleanly make it back to `onChange`. `DndFilterSelect` only calls `setValues` (no `onChange`), and the metric / `AdhocFilterControl` paths commit via `onDropLabel`, which closes over the pre-drag `values`... so the UI order looks right but the committed array is the stale one. I think dragging a metric and reloading would revert the order.
   
   Mind routing the freshly reordered copy through `onChange`? A small test asserting the committed order would pin it down. `optionSelector.reorder` could also use the same bounds guard the others got, since `DndColumnSelect` goes straight through it. Holler if you want a hand. Thanks!
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-5083044672

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-5099474184

   Turns out #41637 already shipped this exact fix in July (splice/arrayMove reorder, committing through `onChange`/`handleChange` instead of the stale `onDropLabel` closure) across `DndMetricSelect`, `DndFilterSelect`, `AdhocFilterControl`, and `OptionSelector`. That's why this keeps drifting into conflicts, it's duplicating code that's already on `master`. I've been driving this branch, so I'll close it out rather than continue to ask for a rebase on something already fixed. Thanks for tracking down the original swap-vs-splice bug, @CoderSxy, it pointed straight at the real root cause.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-4748906584

   @CoderSxy no changes since my last pass, and CI's still red (`lint-frontend` + a jest shard) with the branch needing a rebase. The `AdhocFilterControl/index.jsx` `moveLabel` is still the broken one — `this.values.splice(...)` is undefined (it's `this.state.values`), and `onChange(this.state.values)` hands back the unchanged array. Can you splice a copy of `this.state.values`, `setState` it, then `onChange` that copy?


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-4933559516

   Pushed the three follow-ups, @CoderSxy. Added the bounds guard on `OptionSelector.reorder` so a stale or out-of-range index from a fast drag can't splice `undefined` in.
   
   `DndFilterSelect` now commits via `onChange` after the reorder... it was only doing `setValues`, so the new filter order was never actually persisting.
   
   And the stale drop-commit on the metric/adhoc paths: `moveLabel` now commits the freshly reordered array through `handleChange`, and the drop event is a no-op so it can't re-commit the pre-drag order behind it. Added committed-order tests that assert what reaches `onChange`, not just the rendered order.
   
   CI's running now. Thanks again for diagnosing the original swap-vs-reorder bug!


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #35867:
URL: https://github.com/apache/superset/pull/35867#issuecomment-4910212242

   Circling back on my own rework here since it's gone quiet. Two of the things I flagged still stand, and since this one's on my plate now I'll just push them:
   
   - `optionSelector.reorder` still needs the bounds guard the sibling controls have... an out-of-range index splices `undefined` in, which blows up downstream. Trivial to add.
   - `DndFilterSelect` still only calls `setValues` on reorder, never `onChange`, so the filter order doesn't actually persist. One-liner to route `newValues` through `onChange`.
   
   The trickier one is the metric / `AdhocFilterControl` commit: the reorder shows correctly but `onDropLabel` closes over the pre-drag `values`, so the committed array is stale and a reload reverts the order. That needs the drop-commit to read the freshly reordered copy (a ref, or committing inside the reorder rather than on drop), so I'll sort that out and add a test pinning the committed order. Thanks again @CoderSxy for the original diagnosis.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas closed pull request #35867: fix: drag a metric very quickly,the order is chaotic.
URL: https://github.com/apache/superset/pull/35867


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] fix: drag a metric very quickly,the order is chaotic. [superset]

Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on code in PR #35867:
URL: https://github.com/apache/superset/pull/35867#discussion_r3651982454


##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/utils/optionSelector.ts:
##########
@@ -89,6 +89,11 @@ export class OptionSelector {
     [this.values[a], this.values[b]] = [this.values[b], this.values[a]];
   }
 
+  reorder(from: number, to: number) {
+    const [moved] = this.values.splice(from, 1);
+    this.values.splice(to, 0, moved);
+  }

Review Comment:
   Added a JSDoc block above `reorder` with the `@param` tags.



-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org