codeant-ai-for-open-source[bot] commented on code in PR #42483:
URL: https://github.com/apache/superset/pull/42483#discussion_r3658387540
##########
superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndSelectLabel.tsx:
##########
@@ -87,14 +88,27 @@ export default function DndSelectLabel({
canDrop: dropValidator,
onDrop: props.onDrop,
onDropValue: props.onDropValue,
+ onDropFolder: props.onDropFolder,
},
});
// Check if the active dragged item can be dropped here
const canDrop = useMemo(() => {
if (!active?.data.current) return false;
- const activeData = active.data.current as { type: string; value: unknown };
+ const activeData = active.data.current as {
+ type: string;
+ value?: unknown;
+ items?: DatasourcePanelDndItem[];
+ };
if (!acceptTypes.includes(activeData.type as DndItemType)) return false;
+ // A folder can drop here when at least one of its items is acceptable.
+ if (activeData.type === DndItemType.Folder) {
+ const items = Array.isArray(activeData.items) ? activeData.items : [];
+ return items.some(
+ item =>
+ acceptTypes.includes(item.type as DndItemType) &&
dropValidator(item),
+ );
Review Comment:
**Suggestion:** The folder-specific logic is unreachable for drop zones that
accept columns but not the `Folder` type: the preceding
`acceptTypes.includes(activeData.type)` check returns `false` before inspecting
the folder's child items. As a result, dragging a folder onto dimensions,
groupbys, or metrics will be rejected even when at least one contained item is
valid. Evaluate folder items before applying the direct type acceptance check,
or treat a folder as accepted when one of its items is acceptable. [logic error]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ Folder drops are rejected on dimensions, group-bys, and metrics.
- ⚠️ The PR's primary folder drag-and-drop workflow cannot populate accepted
fields.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open Explore view and create or use a dataset containing a folder with
columns,
following the folder drag-and-drop workflow described in the PR.
2. Begin dragging a folder; the drag state consumed by `DndSelectLabel.tsx`
contains
`active.data.current.type === DndItemType.Folder` and its columns in
`active.data.current.items`.
3. Move the folder over a `DndSelectLabel` drop zone configured to accept
column types for
dimensions, group-bys, or metrics. In `DndSelectLabel.tsx:103`,
`acceptTypes.includes(activeData.type as DndItemType)` evaluates to false
because the
active type is `Folder`.
4. The function returns before reaching the folder-item handling at
`DndSelectLabel.tsx:105-110`, so `dropValidator()` is never evaluated for
the contained
columns and the drop zone reports that the folder cannot be dropped, even
when a child
column is valid.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=59d0a7b07b76426abb4611461fb0e312&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=59d0a7b07b76426abb4611461fb0e312&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/DndSelectLabel.tsx
**Line:** 103:110
**Comment:**
*Logic Error: The folder-specific logic is unreachable for drop zones
that accept columns but not the `Folder` type: the preceding
`acceptTypes.includes(activeData.type)` check returns `false` before inspecting
the folder's child items. As a result, dragging a folder onto dimensions,
groupbys, or metrics will be rejected even when at least one contained item is
valid. Evaluate folder items before applying the direct type acceptance check,
or treat a folder as accepted when one of its items is acceptable.
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%2F42483&comment_hash=4fe69d491da1267b631819d9f941bd724629da1bb6ce586026bcef76e1758e1a&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42483&comment_hash=4fe69d491da1267b631819d9f941bd724629da1bb6ce586026bcef76e1758e1a&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]