Repository navigation
Conversation
An `aria-expanded` written on an `ion-item` was ignored by screen readers. The attribute stayed on the Host, which renders `role="listitem"` when the item is in an `ion-list`. A `listitem` has no expanded state, so the attribute was dropped where it was written and the item read as neither expanded nor collapsed. The same markup on a `div` worked, since a `div` carries the attribute. `aria-expanded` is copied to the native element for the same reason `aria-label` already is: it is a state the assistive technology reads off the element that takes the action. Every other Ionic component that has one puts it there too — `ion-accordion` on the native button of its header item, `ion-select` and `ion-datetime` on their own focusable element. Fixes ionic-team#30558
|
@OMD-123 is attempting to deploy a commit to the Ionic Team on Vercel. A member of the Team first needs to authorize it. |
3 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: resolves #30558
What is the current behavior?
An
aria-expandedwritten on anion-itemis ignored by screen readers.The attribute stays on the Host, which renders
role="listitem"when the item is in anion-list. Alistitemhas no expanded state, so the attribute is dropped where it was written, and the item reads as neither expanded nor collapsed.The same markup on a
divworks, because adivcarries the attribute:What is the new behavior?
aria-expandedis copied to the native element, the same wayaria-labelalready is. It is a state the assistive technology reads off the element that takes the action, and that is where the other Ionic components put it too:ion-accordionsets it on the native<button>of its header itemion-selectsets it on its own focusable elemention-datetimesets it on the native<button>of its time bodyDoes this introduce a breaking change?
aria-expandedwas previously ignored on anion-item, so nothing that worked before changes. The attribute is still left on the Host for a non-clickable item, which has no native element to carry it — the same rulearia-labelalready follows.Testing
Two tests were added to
core/src/components/item/test/a11y/item.e2e.ts, next to the existingshould reflect aria-labeltest:should reflect aria-expanded— the attribute written on the item reaches the native element, on a plain item and on a clickable oneshould reflect aria-expanded written after load— the attribute written after the item has loaded also reaches the native elementAgainst
mainthey fail with the attribute readingnullon the native element:With this change they pass. The rest of the suite is unchanged:
core/src/components/item/test/a11y/item.e2e.ts— 25 passed (Chrome)core/src/components/item/— 165 passed (Chrome, Firefox, Safari)eslintandprettier --checkclean on the changed files