fix: a11y bug aria-expanded not supported here [AC-4117]#1330
fix: a11y bug aria-expanded not supported here [AC-4117]#1330Stefan3002 wants to merge 1 commit intocanonical:mainfrom
Conversation
d0aebee to
780aff2
Compare
There was a problem hiding this comment.
Pull request overview
Fixes accessibility violations in the SearchAndFilter UI by moving aria-expanded off non-interactive containers and wiring the trigger element to the panel it controls.
Changes:
- Move
aria-expandedfrom a container<div>onto the search<input>and addaria-controls+ anidon the controlled panel. - Update click handling so clicking the search/filter area expands the internal “expanded” state.
- Remove
aria-expandedfrom the filter panel chips wrapper and dropuseEffectEventusage inFilterPanelSection.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/components/SearchAndFilter/SearchAndFilter.tsx | Moves ARIA expanded/controls onto the input and links it to the panel; adjusts click behavior. |
| src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.tsx | Removes invalid aria-expanded usage on a non-interactive div; refactors overflow recalculation callback. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.tsx
Outdated
Show resolved
Hide resolved
62e1bf1 to
6d16c55
Compare
There was a problem hiding this comment.
Pull request overview
Fixes an accessibility validation issue in SearchAndFilter by relocating aria-expanded from non-interactive containers to a more appropriate control and linking the trigger to the panel via aria-controls.
Changes:
- Move
aria-expandedfrom a<div>onto the<input>and addrole="combobox"plusaria-controls. - Add a stable
idon the filter panel container foraria-controlstargeting. - Remove
aria-expandedfrom a<div>inFilterPanelSectionand replaceuseEffectEventusage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/components/SearchAndFilter/SearchAndFilter.tsx | Moves ARIA state to the input, adds aria-controls, and assigns an id to the panel. |
| src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.tsx | Removes invalid aria-expanded usage and replaces useEffectEvent with a local function. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.tsx
Outdated
Show resolved
Hide resolved
29f48cb to
3063e18
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses an accessibility rule violation in the SearchAndFilter control by moving aria-expanded off non-interactive containers and linking the element that toggles the panel to the panel via ARIA attributes.
Changes:
- Move
aria-expandedfrom a wrapper<div>to the<input>and addaria-controlslinkage to the panel. - Add a fixed
idto the panel to supportaria-controls. - Remove
aria-expandedfrom the FilterPanelSection chips wrapper<div>.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/components/SearchAndFilter/SearchAndFilter.tsx | Moves expansion semantics to the input (adds role="combobox", aria-expanded, aria-controls) and adds an id to the panel. |
| src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.tsx | Removes aria-expanded from a non-interactive chips wrapper element. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.tsx
Show resolved
Hide resolved
3063e18 to
c8b530c
Compare
c8b530c to
007cb88
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses an accessibility validation issue in the SearchAndFilter components by removing aria-expanded from non-interactive containers and updating related UI/test expectations.
Changes:
- Replace
aria-expandedon the SearchAndFilter search container withdata-expanded. - Remove
aria-expandedfrom the FilterPanelSection chips wrapper and adjust tests/snapshots accordingly. - Improve Chip dismiss button accessibility by adding an
aria-labeland marking the icon asaria-hidden.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/components/SearchAndFilter/SearchAndFilter.tsx |
Replaces aria-expanded on a <div> with data-expanded. |
src/components/SearchAndFilter/__snapshots__/SearchAndFilter.test.tsx.snap |
Updates snapshot to reflect data-expanded instead of aria-expanded. |
src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.tsx |
Removes aria-expanded from the chips wrapper <div>. |
src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.test.tsx |
Updates the overflow/expansion test expectations and setup. |
src/components/SearchAndFilter/FilterPanelSection/__snapshots__/FilterPanelSection.test.tsx.snap |
Updates snapshot to remove aria-expanded. |
src/components/Chip/Chip.tsx |
Adds aria-label to dismiss button and hides decorative icon from AT. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.test.tsx
Show resolved
Hide resolved
src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.tsx
Show resolved
Hide resolved
007cb88 to
b80be8c
Compare
b80be8c to
4352a26
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses an accessibility validator issue in the SearchAndFilter UI by removing/avoiding invalid aria-expanded usage on non-interactive elements and updating related component tests and snapshots.
Changes:
- Replaced
aria-expandedon the SearchAndFilter containerdivwith a non-ARIA state attribute (data-expanded) and removedaria-expandedfrom the FilterPanelSection chips wrapperdiv. - Improved Chip dismiss button accessibility by adding an
aria-labeland marking the close icon asaria-hidden. - Updated tests and snapshots to reflect the new attributes and accessible names, including adding an overflow/counter interaction test for FilterPanelSection.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/SearchAndFilter/SearchAndFilter.tsx | Replaces aria-expanded with data-expanded on the search container. |
| src/components/SearchAndFilter/SearchAndFilter.test.tsx | Updates assertions around expansion and updates dismiss button accessible name usage. |
| src/components/SearchAndFilter/snapshots/SearchAndFilter.test.tsx.snap | Snapshot updated for data-expanded instead of aria-expanded. |
| src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.tsx | Removes aria-expanded from chips wrapper. |
| src/components/SearchAndFilter/FilterPanelSection/FilterPanelSection.test.tsx | Adds/updates overflow counter interaction testing. |
| src/components/SearchAndFilter/FilterPanelSection/snapshots/FilterPanelSection.test.tsx.snap | Snapshot updated after removing aria-expanded. |
| src/components/Chip/Chip.tsx | Adds aria-label to dismiss button and hides icon from AT. |
| src/components/Chip/Chip.test.tsx | Updates expectations for the dismiss button accessible name. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Jest is unaware of layout so we must mock the offsetTop and offsetHeight | ||
| // of the chips to force the overflow counter to show. | ||
| Object.defineProperty(HTMLElement.prototype, "offsetHeight", { | ||
| configurable: true, | ||
| value: 40, | ||
| }); | ||
| Object.defineProperty(HTMLElement.prototype, "offsetTop", { | ||
| configurable: true, | ||
| value: 100, | ||
| }); |
| aria-expanded={expanded} | ||
| ref={chipWrapper} | ||
| > | ||
| <div className="p-filter-panel-section__chips" ref={chipWrapper}> |
Done
aria-expandedattribute is not allowed on a div.QA
Pinging @canonical/react-library-maintainers for a review.
We can run axe-core quickly like so:
npx @axe-core/cli http://localhost:5173/ --verboseI used the following
App.tsxfile to test:REFS:
"Required States and Properties:
aria-controls
aria-expanded" for combobox
Fixes
Fixes: #AC-4117.