codeant-ai-for-open-source[bot] commented on code in PR #42009:
URL: https://github.com/apache/superset/pull/42009#discussion_r3573556396


##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterConfigurationLink/index.tsx:
##########
@@ -32,6 +33,7 @@ export const FilterConfigurationLink: FC<FCBProps> = ({
   <div
     {...getFilterBarTestId('create-filter')}
     onClick={onClick}
+    onKeyDown={handleKeyboardActivation(onClick)}

Review Comment:
   **Suggestion:** `onClick` is optional in this component, but 
`handleKeyboardActivation` always invokes the callback for Enter/Space. When 
this link is rendered without `onClick` (for example in `FilterBarSettings`), 
pressing Enter/Space will throw a runtime `TypeError` because the callback is 
`undefined`. Guard the keyboard handler when no callback is provided (or make 
`onClick` required). [api mismatch]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ Keyboard Enter/Space on config link throws TypeError.
   - ⚠️ Dashboard horizontal filter bar settings unusable via keyboard.
   ```
   </details>
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Inspect `FilterConfigurationLink` in
   
`superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterConfigurationLink/index.tsx:24-41`,
   where `onClick` is declared optional (`onClick?: () => void;`) and passed 
directly into
   `onKeyDown={handleKeyboardActivation(onClick)}` at line 36.
   
   2. Inspect the keyboard helper implementation in
   
`superset-frontend/packages/superset-ui-core/src/utils/handleKeyboardActivation.ts:30-39`,
   where `handleKeyboardActivation` takes a required `callback: (event: 
KeyboardEvent) =>
   void` and, on Enter/Space, calls `callback(event)` without any 
null/undefined guard.
   
   3. Inspect `FilterBarSettings` in
   
`superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBarSettings/index.tsx:166-177`,
   where the menu items are built and the "Add or edit filters and controls" 
entry is created
   with `label: (<FilterConfigurationLink>...</FilterConfigurationLink>)` at 
lines 171-176,
   providing no `onClick` prop to `FilterConfigurationLink`.
   
   4. Render `FilterBarSettings` within the horizontal filter bar (see 
`HorizontalFilterBar`
   usage at
   
`superset-frontend/src/dashboard/components/nativeFilters/FilterBar/Horizontal.tsx:15-17`
   where `<FilterBarSettings />` is included), open its dropdown, Tab focus 
onto the inner
   `FilterConfigurationLink` element (which is focusable due to 
`tabIndex={0}`), then press
   Enter or Space: the `onKeyDown` handler built by 
`handleKeyboardActivation(onClick)`
   executes `callback(event)` where `callback` is `undefined`, causing a 
runtime `TypeError:
   callback is not a function`.
   ```
   </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=bdda2b3fa501445f87e6b49294ab9c5d&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=bdda2b3fa501445f87e6b49294ab9c5d&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/dashboard/components/nativeFilters/FilterBar/FilterConfigurationLink/index.tsx
   **Line:** 36:36
   **Comment:**
        *Api Mismatch: `onClick` is optional in this component, but 
`handleKeyboardActivation` always invokes the callback for Enter/Space. When 
this link is rendered without `onClick` (for example in `FilterBarSettings`), 
pressing Enter/Space will throw a runtime `TypeError` because the callback is 
`undefined`. Guard the keyboard handler when no callback is provided (or make 
`onClick` required).
   
   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=772317095f09c3d844d99630fbc2c400160a6febfd43228d77ec25a3762fc315&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42009&comment_hash=772317095f09c3d844d99630fbc2c400160a6febfd43228d77ec25a3762fc315&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]

Reply via email to