codeant-ai-for-open-source[bot] commented on code in PR #39863:
URL: https://github.com/apache/superset/pull/39863#discussion_r3503491352
##########
superset-frontend/src/explore/components/controls/CollectionControl/index.tsx:
##########
@@ -116,8 +124,17 @@ function SortableItem({
paddingInline: theme.sizeUnit * 6,
})}
>
- <span {...attributes} {...listeners}>
- <DragHandle />
+ <span ref={setActivatorNodeRef} css={{ display: 'inline-flex' }}>
Review Comment:
**Suggestion:** `setActivatorNodeRef` is attached to a wrapping `span`
instead of the actual interactive drag handle button. In dnd-kit this ref
should point to the real activator element so keyboard drag focus is restored
correctly; keeping it on a non-interactive wrapper can cause focus to land
incorrectly (or be lost) after keyboard reordering. Attach
`setActivatorNodeRef` directly to the button element. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Keyboard drag handle focus misplaced after reordering operations.
- ⚠️ Explore control panels less accessible for keyboard-only users.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. The Explore control rendering pipeline uses `controlMap` from
`src/explore/components/controls/index.ts:72-77`, and `Control.tsx:12-15`
selects the
React component by `type` string, so any control with `type:
'CollectionControl'` will
render `CollectionControl` from
`superset-frontend/src/explore/components/controls/CollectionControl/index.tsx`.
2. Inside `CollectionControl`, each row is wrapped in `SortableItem` which
calls
`useSortable({ id })` at `index.tsx:98-105`, obtaining `attributes`,
`listeners`,
`setNodeRef`, and `setActivatorNodeRef` to wire up drag-and-drop behavior,
including the
`KeyboardSensor` configured in `CollectionControl` at `index.tsx:199-206`.
3. The drag handle markup in `SortableItem` is rendered at
`index.tsx:127-137` as a `span`
with `ref={setActivatorNodeRef}` (`line 127`) containing a `Button` which
receives the
dnd-kit `attributes` and `listeners` plus `aria-label="Drag to reorder"`;
tests at
`CollectionControl.test.tsx:68-73` confirm the activator element exposed to
users is this
`BUTTON`.
4. dnd-kit’s `setActivatorNodeRef` is designed to reference the actual
activator element
(the same element that gets `attributes`/`listeners`) so that keyboard
sensors and focus
restoration can target it; here, the ref instead points to the
non-interactive wrapper
`span`, so after performing keyboard-based reordering (Space + arrow keys on
the drag
handle button) the library will restore focus to the `span` rather than the
`BUTTON`,
causing focus to land on a non-interactive container and potentially be lost
or invisible
to keyboard and screen-reader users. Attaching `setActivatorNodeRef`
directly to the
`Button` would align with dnd-kit’s documented pattern and avoid this
mismatch.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=fe11f82cbee348c19e339939d0c02a7d&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=fe11f82cbee348c19e339939d0c02a7d&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/CollectionControl/index.tsx
**Line:** 127:127
**Comment:**
*Logic Error: `setActivatorNodeRef` is attached to a wrapping `span`
instead of the actual interactive drag handle button. In dnd-kit this ref
should point to the real activator element so keyboard drag focus is restored
correctly; keeping it on a non-interactive wrapper can cause focus to land
incorrectly (or be lost) after keyboard reordering. Attach
`setActivatorNodeRef` directly to the button element.
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%2F39863&comment_hash=5409e55de01be273c5b237229656e16b8e7a47cf161ccd6e4e7d245fde9bfbc9&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39863&comment_hash=5409e55de01be273c5b237229656e16b8e7a47cf161ccd6e4e7d245fde9bfbc9&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]