Skip to content

fix(react): don't render false boolean props as attributes#31294

Open
ShaneK wants to merge 1 commit into
major-9.0from
FW-7393-2
Open

fix(react): don't render false boolean props as attributes#31294
ShaneK wants to merge 1 commit into
major-9.0from
FW-7393-2

Conversation

@ShaneK

@ShaneK ShaneK commented Jul 23, 2026

Copy link
Copy Markdown
Member

Issue number: resolves #27930


What is the current behavior?

Currently, passing a falsy boolean prop like disabled={false} in @ionic/react renders the host as <ion-button disabled="false">. disabled is an HTML boolean attribute, so its mere presence means "true" to assistive tech regardless of the value, and VoiceOver treats the button as disabled even though Ionic renders and behaves as enabled.

On v9 the new @lit/react runtime fixes this for the generated components, but the hand-rolled wrappers (createReactComponent, createRoutingComponent) still serialize booleans to attributes and sync props through attachProps. So ion-button, ion-card, ion-fab-button, ion-item-option, ion-breadcrumb, ion-router-link, ion-back-button, and ion-tab-button keep the stray attribute.

What is the new behavior?

attachProps now removes a stray ="false" attribute after assigning the property, for any boolean prop that resolves to false. aria-* and data-* attributes and the enumerated attributes (draggable, translate, spell-check, content-editable) are excluded, since "false" is meaningful there and differs from the attribute being absent. disabled={true} still renders the attribute and disables the control. Because the property is already the source of truth and React doesn't re-add an unchanged attribute, this holds across re-renders.

Does this introduce a breaking change?

  • Yes
  • No

Other information

Tested at three levels: attachProps unit tests (utils.spec.ts), integration tests through the real createReactComponent and createRoutingComponent wrappers, and a real-browser Playwright e2e in the react-router test app (new /disabled-button route) that asserts a real IonButton with disabled={false} carries no disabled attribute and its inner native button stays interactive, while disabled={true} disables it.

Manual test page (after the branch deploys):

@ShaneK
ShaneK requested a review from a team as a code owner July 23, 2026 20:11
@ShaneK
ShaneK requested a review from brandyscarney July 23, 2026 20:11
@vercel

vercel Bot commented Jul 23, 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 23, 2026 8:12pm

Request Review

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

Labels

package: react @ionic/react package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant