fix(DataMapper): activate summary buttons with Enter and Space#3540
Conversation
The ExpansionPanel summary is a role="button" div whose keydown handler called preventDefault() on Enter/Space. Because React's onKeyDown bubbles, this also cancelled the browser's activation behaviour for any focused descendant, so no click was ever synthesised and the button's onClick never ran. Only mouse clicks worked. This affected every button rendered in a panel summary, including the add/rename/delete parameter actions, not just the add-parameter confirm button reported in the issue. - Ignore keydown events that did not originate on the summary itself, so interactive descendants keep their native Enter/Space activation. - Stop click propagation on the name input confirm/cancel buttons, so activating them no longer toggles the enclosing panel. This was also reachable with the mouse, most visibly when renaming a parameter, where the panel survives the action and toggled underneath the user. Fixes KaotoIO#3536
📝 WalkthroughWalkthroughExpansionPanel keyboard handling now ignores events from interactive descendants. NameInputPlaceholder stops submit and cancel clicks from toggling the enclosing panel, with tests covering Enter, Space, Tab, and Escape interactions. ChangesKeyboard interaction behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/ui/src/components/ExpansionPanels/ExpansionPanel.tsx`:
- Around line 116-118: The ExpansionPanel summary click path still toggles when
a nested interactive control is activated. In
packages/ui/src/components/ExpansionPanels/ExpansionPanel.tsx:116-118, update
the summary click handling around toggleExpanded to ignore supported interactive
descendant targets while preserving their native activation; in
packages/ui/src/components/ExpansionPanels/ExpansionPanel.test.tsx:478-493,
provide a setExpanded mock and assert it is not called after nested-button Enter
or Space activation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c1d24b8f-c8e1-4b37-9e37-75b66e446199
📒 Files selected for processing (4)
packages/ui/src/components/Document/NameInputPlaceholder.test.tsxpackages/ui/src/components/Document/NameInputPlaceholder.tsxpackages/ui/src/components/ExpansionPanels/ExpansionPanel.test.tsxpackages/ui/src/components/ExpansionPanels/ExpansionPanel.tsx



The ExpansionPanel summary is a role="button" div whose keydown handler called preventDefault() on Enter/Space. Because React's onKeyDown bubbles, this also cancelled the browser's activation behaviour for any focused descendant, so no click was ever synthesised and the button's onClick never ran. Only mouse clicks worked.
This affected every button rendered in a panel summary, including the add/rename/delete parameter actions, not just the add-parameter confirm button reported in the issue.
Fixes #3536
I used a stack of agents, Fable in front, a mix of local models on my Spark and workstation, to address this issue and solve it. I'm learning the trade via "project based learning", so i read the diff here and spent time with my agents to understand what we did and why. I think I've put my inference to good use here for you guys and the open source movement.
Thank you!
Summary by CodeRabbit
Bug Fixes
Accessibility