Skip to content

fix(item): copy aria-expanded to the native element - #31810

Open
OMD-123 wants to merge 1 commit into
ionic-team:mainfrom
OMD-123:fix/item-aria-expanded
Open

OMD-123 wants to merge 1 commit into
ionic-team:mainfrom
OMD-123:fix/item-aria-expanded

Conversation

@OMD-123

@OMD-123 OMD-123 commented Nov 23, 2026 •

Copy link
Copy Markdown

Issue number: resolves #30558

What is the current behavior?

An aria-expanded written on an ion-item is ignored by screen readers.

The attribute stays on the Host, which renders role="listitem" when the item is in an ion-list. A listitem has 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 div works, because a div carries the attribute:

<!-- read as "Content title" only -->
<ion-item aria-expanded="false">Content title</ion-item>

<!-- read as "Collapsed. Content title" -->
<div aria-expanded="false">Content title</div>

What is the new behavior?

aria-expanded is copied to the native element, the same way aria-label already 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-accordion sets it on the native <button> of its header item
  • ion-select sets it on its own focusable element
  • ion-datetime sets it on the native <button> of its time body

Does this introduce a breaking change?

  • Yes
  • No

aria-expanded was previously ignored on an ion-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 rule aria-label already follows.

Testing

Two tests were added to core/src/components/item/test/a11y/item.e2e.ts, next to the existing should reflect aria-label test:

  • should reflect aria-expanded — the attribute written on the item reaches the native element, on a plain item and on a clickable one
  • should reflect aria-expanded written after load — the attribute written after the item has loaded also reaches the native element

Against main they fail with the attribute reading null on the native element:

Expected: "false"
Received: null

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)
  • the full core spec suite — 912 passed, 105 suites, 0 failures
  • eslint and prettier --check clean on the changed files

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
OMD-123 requested a review from a team as a code owner November 23, 2026 18:18
@OMD-123
OMD-123 requested a review from ShaneK November 23, 2026 18:18
@vercel

vercel Bot commented Nov 23, 2026

Copy link
Copy Markdown

@OMD-123 is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: aria-expanded is ignored when used in ion-item (TalkBack)

1 participant