codeant-ai-for-open-source[bot] commented on code in PR #42009:
URL: https://github.com/apache/superset/pull/42009#discussion_r3573574157
##########
superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx:
##########
@@ -1760,6 +1761,7 @@ function DatasourceEditor({
role="button"
tabIndex={0}
onClick={onChangeEditMode}
+ onKeyDown={handleKeyboardActivation(onChangeEditMode)}
Review Comment:
**Suggestion:** This keydown activation path can fire repeatedly while
Enter/Space is held (keydown auto-repeat), so `onChangeEditMode` may run
multiple times for one user action and rapidly toggle edit lock state back and
forth. Use a non-repeating trigger (e.g., ignore `event.repeat` or trigger on
keyup) to ensure one toggle per activation. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ⚠️ Edit lock in Datasource editor may toggle unpredictably.
- ⚠️ Keyboard users may see inconsistent editing lock state.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Open the datasource editing modal
(superset-frontend/src/components/Datasource/DatasourceModal/index.tsx lines
383-385)
which renders the DatasourceEditor component, mounting
superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx.
2. In DatasourceEditor.tsx, note the edit-mode state at lines 878-882
(`const [isEditMode,
setIsEditMode] = useState(false);`) and the toggle handler at lines
1055-1058:
`onChangeEditMode` calls `setIsEditing(!isEditMode)` and `setIsEditMode(prev
=> !prev)` to
flip the edit lock state.
3. The lock icon in the source fieldset at lines 1755-1764 is rendered as a
keyboard-focusable span: `<span role="button" tabIndex={0}
onClick={onChangeEditMode}
onKeyDown={handleKeyboardActivation(onChangeEditMode)}>`, wiring both mouse
clicks and
keydown events to `onChangeEditMode`.
4. The shared helper in
superset-frontend/packages/superset-ui-core/src/utils/handleKeyboardActivation.ts
(lines
30-40) returns an `onKeyDown` handler that calls the callback on every Enter
or Space
keydown, without checking `event.repeat`. When a keyboard user tabs to the
lock icon and
holds Enter or Space, the browser’s auto-repeat generates multiple keydown
events, each
invoking `onChangeEditMode` and flipping `isEditMode` back and forth; the
final
locked/unlocked state after a single long press can therefore differ from the
single-toggle behavior of a mouse click, producing inconsistent edit lock
behavior.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=a38071803e8540e8acee6b839017efde&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=a38071803e8540e8acee6b839017efde&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/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx
**Line:** 1764:1764
**Comment:**
*Logic Error: This keydown activation path can fire repeatedly while
Enter/Space is held (keydown auto-repeat), so `onChangeEditMode` may run
multiple times for one user action and rapidly toggle edit lock state back and
forth. Use a non-repeating trigger (e.g., ignore `event.repeat` or trigger on
keyup) to ensure one toggle per activation.
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%2F42009&comment_hash=32a5ab8d724042cd245c45f6543b497bbf054f97bc6f6fdd47a8df4bf7e9a3eb&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42009&comment_hash=32a5ab8d724042cd245c45f6543b497bbf054f97bc6f6fdd47a8df4bf7e9a3eb&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]