-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
a11y(tools): replace div+onClick with semantic button elements (#5223) #5350
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -176,31 +176,33 @@ export default function ToolsDashboard() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className='my-10 flex flex-wrap justify-between gap-4 lg:flex-nowrap'> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className='flex h-auto w-[47%] gap-5 lg:w-1/5'> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className='relative h-auto w-full' ref={filterRef as React.LegacyRef<HTMLDivElement>}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type='button' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className='flex h-14 w-full cursor-pointer items-center justify-center gap-2 rounded-lg border border-gray-300 px-4 py-1 text-sm text-gray-700 shadow hover:border-gray-600 hover:shadow-md' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => setOpenFilter(!openFilter)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data-testid='ToolsDashboard-Filters-Click' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <FilterIcon /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div>Filter</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span>Filter</span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {openFilter && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button className='absolute top-16 z-20 min-w-[20rem]'> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className='absolute top-16 z-20 min-w-[20rem]' role='menu'> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Filters setOpenFilter={setOpenFilter} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className='flex h-auto w-[47%] gap-5 lg:w-1/5'> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className='relative h-auto w-full' ref={categoryRef as React.LegacyRef<HTMLDivElement>}> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type='button' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className='flex h-14 w-full cursor-pointer items-center justify-center gap-2 rounded-lg border border-gray-300 px-4 py-1 text-sm text-gray-700 shadow hover:border-gray-600 hover:shadow-md' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => setopenCategory(!openCategory)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data-testid='ToolsDashboard-category' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div>Jump to Category</div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <span>Jump to Category</span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ArrowDown className={`my-auto ${openCategory ? 'rotate-180' : ''}`} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {openCategory && ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className='absolute right-52 top-16 z-20'> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+197
to
207
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expose the Jump to Category expanded state. The trigger is now keyboard-operable, but screen readers still won’t know whether the dropdown is open. Add ♿ Proposed fix <button
type='button'
+ aria-expanded={openCategory}
+ aria-controls='tools-category-dropdown'
className='flex h-14 w-full cursor-pointer items-center justify-center gap-2 rounded-lg border border-gray-300 px-4 py-1 text-sm text-gray-700 shadow hover:border-gray-600 hover:shadow-md'
onClick={() => setopenCategory(!openCategory)}
data-testid='ToolsDashboard-category'
>
@@
</button>
{openCategory && (
- <div className='absolute right-52 top-16 z-20'>
+ <div id='tools-category-dropdown' className='absolute right-52 top-16 z-20'>
<CategoryDropdown setopenCategory={setopenCategory} />
</div>
)}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <CategoryDropdown setopenCategory={setopenCategory} /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
Don’t expose the filter panel as an ARIA menu.
Line 189 adds
role='menu', butFiltersrenders form-like controls rather thanmenuitemdescendants. Use a plain container and wire it to the trigger with expanded/control state.♿ Proposed fix
<button type='button' + aria-expanded={openFilter} + aria-controls='tools-filter-panel' className='flex h-14 w-full cursor-pointer items-center justify-center gap-2 rounded-lg border border-gray-300 px-4 py-1 text-sm text-gray-700 shadow hover:border-gray-600 hover:shadow-md' onClick={() => setOpenFilter(!openFilter)} data-testid='ToolsDashboard-Filters-Click' > @@ </button> {openFilter && ( - <div className='absolute top-16 z-20 min-w-[20rem]' role='menu'> + <div id='tools-filter-panel' className='absolute top-16 z-20 min-w-[20rem]'> <Filters setOpenFilter={setOpenFilter} /> </div> )}📝 Committable suggestion
🤖 Prompt for AI Agents