codeant-ai-for-open-source[bot] commented on code in PR #42009:
URL: https://github.com/apache/superset/pull/42009#discussion_r3578591573
##########
superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTable/components/CustomHeader.tsx:
##########
@@ -247,7 +266,13 @@ const CustomHeader: React.FC<CustomHeaderParams> = ({
isOpen={isMenuVisible}
onClose={() => setMenuVisible(false)}
>
- <div className="three-dots-menu" onClick={handleMenuClick}>
+ <div
+ role="button"
+ tabIndex={0}
+ className="three-dots-menu"
+ onClick={handleMenuClick}
+ onKeyDown={handleKeyboardActivation(handleMenuClick)}
Review Comment:
**Suggestion:** Using keyboard activation on a toggle handler causes
repeated keydown events (when Enter/Space is held) to fire the toggle multiple
times, so the menu can immediately re-close or flicker. Guard against
key-repeat (or trigger activation once on keyup) before calling the toggle
callback. [logic error]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Keyboard users can’t reliably open AgGrid header menu.
- ⚠️ Menu flickers when Enter/Space key held down.
- ⚠️ Affects AgGridTable chart server-paginated header menus.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Render an AgGrid table using `TableChart` in
`superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTableChart.tsx:14-50`,
with `serverPagination` enabled so `useColDefs` wires `headerComponent:
CustomHeader` for
columns
(`superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/useColDefs.ts:218-227,380-37`).
2. In the rendered grid, focus a column header’s three-dots menu button,
which is the
`<div className="three-dots-menu">` inside `CustomHeader`
(`superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTable/components/CustomHeader.tsx:240-247`),
using keyboard Tab navigation.
3. Press and hold the Space bar (or Enter key); repeated `keydown` events
are dispatched
to that div, invoking its
`onKeyDown={handleKeyboardActivation(handleMenuClick)}` handler
(`CustomHeader.tsx:260-260`), which calls `handleMenuClick` on every
qualifying keydown
(`handleKeyboardActivation` implementation in
`superset-frontend/packages/superset-ui-core/src/utils/handleKeyboardActivation.ts:30-39`).
4. `handleMenuClick` stops propagation and toggles `isMenuVisible` via
`setMenuVisible(!isMenuVisible)` (`CustomHeader.tsx:123-125,190-193`), so
each repeated
keydown flips the visibility; holding the key rapidly opens then closes the
popover
(`CustomPopover` controlled by `isMenuVisible` at `CustomHeader.tsx:4-8`),
causing the
header menu to flicker or end up closed instead of staying open after a
single activation.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=e8e188a5c39245ca92edf0aa39e29345&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=e8e188a5c39245ca92edf0aa39e29345&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/plugins/plugin-chart-ag-grid-table/src/AgGridTable/components/CustomHeader.tsx
**Line:** 274:274
**Comment:**
*Logic Error: Using keyboard activation on a toggle handler causes
repeated keydown events (when Enter/Space is held) to fire the toggle multiple
times, so the menu can immediately re-close or flicker. Guard against
key-repeat (or trigger activation once on keyup) before calling the toggle
callback.
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=b0fa008012ee56d84feb7d671f21a46eb74aabf9a9ea5b83a85b8a28bc32d027&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42009&comment_hash=b0fa008012ee56d84feb7d671f21a46eb74aabf9a9ea5b83a85b8a28bc32d027&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]