-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Filters] Ensure aria-expanded is not set to undefined on mount #2589
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
9641be7
to
afb7fb3
Compare
💦 Potential splash zone of changes introduced to No significant changes to This comment automatically updates as changes are made to this pull request. |
It's interesting that the Popover's type definition expect |
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.
Mind adding a test? Otherwise looks good! 👍
afb7fb3
to
3335c89
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 so much for fixing this, @francinen!
UNRELEASED.md
Outdated
|
||
- Fixed issue with `Filters` component displaying an undesired margin top and bottom on the button element on Safari ([#2292](https://github.com/Shopify/polaris-react/pull/2292)) | ||
|
||
- Fixed an issue with `Filters` component where the `aria-expanded` attribute was set to an invalid value on mount ([#2589]https://github.com/Shopify/polaris-react/pull/2589) |
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.
- Fixed an issue with `Filters` component where the `aria-expanded` attribute was set to an invalid value on mount ([#2589]https://github.com/Shopify/polaris-react/pull/2589) | |
- Fixed an issue with the `Filters` component where the `aria-expanded` attribute was `undefined` on mount ([#2589](https://github.com/Shopify/polaris-react/pull/2589)) |
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.
Just a small tweak to the changelog entry, otherwise 👍
3335c89
to
9dc8e09
Compare
WHY are these changes introduced?
When the Filters components mounts onto the DOM, the
aria-expanded
attribute on the Popover activator is set toundefined
, which is an invalid value; thearia-expanded
attribute should be set to eithertrue
orfalse
.This results in an error when running a Lighthouse accessibility audit on a page that uses the Filters component.
The
aria-expanded
attribute is set totrue
orfalse
once a user starts interacting with the Popover activator.WHAT is this pull request doing?
This PR ensures the
aria-expanded
attribute of the Popover activator in the Filters component is always set to eithertrue
orfalse
.The activator's
aria-expanded
attribute is determined by thepopoverOpen
key of a given action, which is set to the value ofthis.state[`${key}${Suffix.Shortcut}`]
in the Filters component.On mount, however,
this.state[`${key}${Suffix.Shortcut}`]
is undefined.The state key for a filter action gets defined when the popover is either opened or closed on click, but it is not initialized on mount.
To ensure the
aria-expanded
attribute is set to eithertrue
orfalse
, this PR transforms the value ofthis.state[`${key}${Suffix.Shortcut}`]
into a Boolean when setting thepopoverOpen
key of a given action:How to 🎩
🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines
Copy-paste this code in
playground/Playground.tsx
:🎩 checklist
README.md
with documentation changes