-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
A11y: Make search clear button keyboard accessible #32590
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
base: next
Are you sure you want to change the base?
A11y: Make search clear button keyboard accessible #32590
Conversation
WalkthroughThe Search.tsx component now renders the clear button based on the presence of input text (inputValue) instead of the menu open state. The button includes an aria-label and, when activated, calls Downshift's reset({ inputValue: '' }) and then closeMenu(), replacing the previous clearSelection behavior. The button remains a CloseIcon and is only rendered while input text exists. Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant SearchInput
participant ClearButton
participant Downshift
participant Menu
rect rgb(245,245,255)
note right of SearchInput: Clear button visible only when inputValue !== ''
User->>SearchInput: Type query
SearchInput-->>ClearButton: Becomes visible
end
alt Activate clear (click/Enter/Space)
User->>ClearButton: Activate
ClearButton->>Downshift: reset({ inputValue: '' })
Downshift-->>SearchInput: input cleared
ClearButton->>Menu: closeMenu()
Menu-->>User: Menu closed
SearchInput-->>ClearButton: Hides (inputValue === '')
else No input present
ClearButton--x User: Not rendered / not reachable
end
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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 |
d44b51a
to
818d81f
Compare
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.
Thanks for attempting a fix on this issue, @ritoban23!
Unfortunately, we've since noticed that the issue is a regression on a specific branch (a11y-consolidation
) and we've found and fixed the root cause for this regression. So, I'll be closing the GitHub issue.
I want to discuss your changes to the event handler before closing the PR though. Could you please walk me through what it does?
<IconButton onClick={() => clearSelection()}> | ||
{input && ( | ||
<IconButton | ||
aria-label="Clear search" |
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.
This will be fixed upstream with changes to the button component, so it won't be necessary :)
@Sidnioulz hello , apologies for the late reply....I tried to explain my proposed changes to the best of my understanding hope it helps! |
Absolutely, thank you for this contribution! |
View your CI Pipeline Execution ↗ for commit 6116541
☁️ Nx Cloud last updated this comment at |
Closes #32582
What I did
Fixed the search clear button keyboard accessibility issue by changing the button's visibility condition from
isOpen
toinput
. This ensures the clear button remains visible and focusable even when the search input loses focus, allowing keyboard users to tab to and activate it. Also added properaria-label
for screen readers and improved the clear functionality.Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
cd code && yarn storybook:ui
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/core
team here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>
Summary by CodeRabbit