Skip to content

fix(button): sync aria description between host and native button - #31264

Open
Zac-Smucker-Bryan wants to merge 4 commits into
ionic-team:mainfrom
Zac-Smucker-Bryan:button-aria-description
Open

fix(button): sync aria description between host and native button#31264
Zac-Smucker-Bryan wants to merge 4 commits into
ionic-team:mainfrom
Zac-Smucker-Bryan:button-aria-description

Conversation

@Zac-Smucker-Bryan

@Zac-Smucker-Bryan Zac-Smucker-Bryan commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Issue number: resolves #30626


What is the current behavior?

The native button inside ion-button is not being updated with the aria-attributes if it changes on ion-button after initial render, including aria-description.

What is the new behavior?

The native button inside ion-button updates with the aria attributes if it changes on ion-button. Changes include:

  • Add 2 helper functions to helpers.ts
    • A mutation observer watching for all attribute changes.
    • One which watches only for aria attribute changes, which calls the mutation observer.
    • Added Export to ariaAttributes so it could be imported for use in tests
  • Add 2 tests to button.e2e.ts in a11y:
    • One which loops through each aria attribute (imported from the helper) using ariaAttributes
    • One which specifically tests aria-disabled since it is managed in render() separately
  • Update button.tsx to:
    • Add import of new helpers watchForAriaAttributeChanges, type AttributeWatcher from '@utils/helpers'
    • Add private ariaWatcher?: AttributeWatcher; to class Button
    • Remove previous watch block since now handled by helper
  • In componentWillLoad()
    • Add ariaWatcher and watchForAriaAttributeChanges, replicating functionality of the watch block, but for all aria attributes
    • Add specific exclusion of aria-disabled

Does this introduce a breaking change?

  • Yes
  • No

Adds @watch('aria-description') to button.tsx before onAriaChanged
Set aria description and both buttons should match. Update aria description on host button, and both buttons should still match.
@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

@Zac-Smucker-Bryan is attempting to deploy a commit to the Ionic Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the package: core @ionic/core package label Jul 10, 2026
@Zac-Smucker-Bryan
Zac-Smucker-Bryan marked this pull request as ready for review July 11, 2026 18:09
@Zac-Smucker-Bryan
Zac-Smucker-Bryan requested a review from a team as a code owner July 11, 2026 18:09
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment Jul 13, 2026 1:33pm

Request Review

@ShaneK ShaneK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR!

I talked to the team about this PR and, while it does look solid and solve the issue's title problem, there's a bit more to it than this.

There's actually 2 remaining issues in the original issue that won't be resolved by this PR:

  • Many other aria attributes not being copied
  • Other components that can act like buttons not getting this fix (this was a comment on the issue, but should still be addressed)

The first one I've created an internal follow-up ticket to address because it's much more involved than this solution and something we'll need to review on how to do well. We can't just add 50 @Watchs and call it good.

The second one I'd prefer if we address in this PR

@codeCraft-Ritik codeCraft-Ritik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix! Synchronizing dynamic aria-description updates with the native button improves accessibility while keeping the component behavior consistent. The accompanying test provides good confidence in the change.

Previously, ARIA attributes inherited from the host were only captured once at componentWillLoad. Attributes set or changed after initial load (e.g. by ion-input-password-toggle updating aria-label/aria-pressed as
visibility toggles) were not reflected onto the native button, causing screen readers to announce stale values unless a watch decorator was used for each attribute.

Adds watchAttributes/watchForAriaAttributeChanges to helpers.ts, which use a MutationObserver to keep inherited ARIA attributes in sync for the lifetime of the component. Replaces the previous per-attribute @watch decorators with this more general mechanism.

Update Button.tsx to reflect this and use these new helpers. Add tests to test syncing all attributes.

Fixes ionic-team#30626
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: ion-button aria-description does not reactively change

3 participants