-
Notifications
You must be signed in to change notification settings - Fork 13
fix: add ENTER key support to db-switch #5444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 6d43c2f The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: mfranzke <[email protected]>
Co-authored-by: mfranzke <[email protected]>
Co-authored-by: mfranzke <[email protected]>
Co-authored-by: Michael Kraus <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds ENTER key support to the db-switch component to improve keyboard accessibility, addressing issue #5443. The W3C ARIA switch pattern specifies that both SPACE and ENTER keys should toggle switches, but the component previously only responded to SPACE.
- Added
handleKeyDownmethod that programmatically clicks the input when ENTER is pressed (with disabled state check) - Updated type definitions to include the keyboard handler signature
- Added comprehensive Playwright tests for both ENTER and SPACE key functionality
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/components/src/components/switch/switch.lite.tsx | Implements handleKeyDown handler with ENTER key logic and attaches it to the input element |
| packages/components/src/components/switch/model.ts | Updates DBSwitchDefaultState type to include handleKeyDown method signature and imports GeneralKeyboardEvent |
| packages/components/src/components/switch/switch.spec.tsx | Adds tests for ENTER key toggle functionality and verifies SPACE key backward compatibility |
| .gitignore | Adds **/blob-report to ignore Playwright blob reports |
| .changeset/wise-walls-pretend.md | Documents the patch-level change for all framework outputs |
Co-authored-by: Copilot <[email protected]>
Proposed changes
The db-switch component only responded to SPACE key for toggling, not ENTER. Per W3C ARIA switch patterns, both keys should toggle the switch for proper keyboard accessibility.
resolves #5443
Implementation
handleKeyDownmethod toswitch.lite.tsxthat listens for ENTER key and programmatically clicks the inputDBSwitchDefaultStatetype to include the keyboard handler signatureGenerated across all frameworks
The Mitosis build generates correct keyboard handlers for:
(keydown)="handleKeyDown($event)"onKeyDown={(event) => handleKeyDown(event)}@keydown="async (event) => handleKeyDown(event)"onKeyDown={(event) => this.handleKeyDown(event)}Tests
Added Playwright tests verifying:
Types of changes
Further comments
SPACE key behavior is preserved. Only the specific Angular generator was mentioned in the issue, but the fix applies to all framework outputs since it's implemented in the Mitosis source.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
www-api.ibm.comnode /home/REDACTED/work/core-web/core-web/node_modules/@ibm/telemetry-js/dist/REDACTED-process.js --log=/tmp/ibmtelemetry-20251112T140901257Z-533603.log --config=telemetry.yml(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
🔭🐙🐈 Test this branch here: https://design-system.deutschebahn.com/core-web/review/copilot/fix-db-switch-enter-functionality