Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
thetaPC
left a comment
There was a problem hiding this comment.
LGTM, I do want to point out that I was only able reproduce this issue on React 18, not 19.
| * runtime fixes this for the generated components on v9, but the hand-rolled | ||
| * wrappers (createReactComponent, createRoutingComponent, ...) render attributes | ||
| * directly and sync props through attachProps, so we strip the stray attribute | ||
| * here after the property has been assigned. See FW-7393. |
There was a problem hiding this comment.
Should this include the mention of a ticket? It would be best to include all the info here as tickets may get deleted, moved, etc and won't be reliable.
| import React, { useState } from 'react'; | ||
|
|
||
| /** | ||
| * FW-7393: `<IonButton disabled={false}>` must not render a `disabled="false"` |
There was a problem hiding this comment.
Do we need the ticket reference? Doesn't feel consistent with how we add comments.
| import { ionPageVisible, withTestingMode } from './utils/test-utils'; | ||
|
|
||
| /** | ||
| * FW-7393: `<IonButton disabled={false}>` must not leave a `disabled="false"` |
There was a problem hiding this comment.
Do we need the ticket reference? Doesn't feel consistent with how we add comments.
| * attribute on the host. ion-button is routing-wrapped (createRoutingComponent), | ||
| * so this is the real end-to-end check with an actual @ionic/react component. | ||
| */ | ||
| test.describe('IonButton disabled boolean attribute (FW-7393)', () => { |
There was a problem hiding this comment.
Do we need the ticket reference? Doesn't feel consistent with how we add comments.
| import { createRoutingComponent } from '../createRoutingComponent'; | ||
|
|
||
| /** | ||
| * FW-7393: routing-wrapped components (ion-button, ion-card, ion-fab-button, |
There was a problem hiding this comment.
Do we need the ticket reference? Doesn't feel consistent with how we add comments.
| */ | ||
| const RoutingEl = createRoutingComponent<any, any>('fake-routing-el'); | ||
|
|
||
| describe('createRoutingComponent boolean attributes (FW-7393)', () => { |
There was a problem hiding this comment.
Do we need the ticket reference? Doesn't feel consistent with how we add comments.
| }); | ||
| }); | ||
|
|
||
| describe('attachProps boolean attributes (FW-7393)', () => { |
There was a problem hiding this comment.
Do we need the ticket reference? Doesn't feel consistent with how we add comments.
| import { createReactComponent } from '../createComponent'; | ||
|
|
||
| /** | ||
| * FW-7393: components built with createReactComponent (e.g. IonBackButton, |
There was a problem hiding this comment.
Do we need the ticket reference? Doesn't feel consistent with how we add comments.
| */ | ||
| const ReactEl = createReactComponent<any, any>('fake-react-el'); | ||
|
|
||
| describe('createReactComponent boolean attributes (FW-7393)', () => { |
There was a problem hiding this comment.
Do we need the ticket reference? Doesn't feel consistent with how we add comments.
| <IonReactRouter basename={import.meta.env?.BASE_URL?.replace(/\/$/, '') || undefined}> | ||
| <IonRouterOutlet> | ||
| <Route path="/" element={<Main />} /> | ||
| <Route path="/disabled-button" element={<DisabledButton />} /> |
There was a problem hiding this comment.
Can we add this to the landing page? My concern is new pages might get forgotten over time if we don't put them there.
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">.disabledis 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 throughattachProps. 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?
attachPropsnow removes a stray="false"attribute after assigning the property, for any boolean prop that resolves tofalse.aria-*anddata-*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?
Other information
Tested at three levels:
attachPropsunit tests (utils.spec.ts), integration tests through the realcreateReactComponentandcreateRoutingComponentwrappers, and a real-browser Playwright e2e in the react-router test app (new/disabled-buttonroute) that asserts a realIonButtonwithdisabled={false}carries nodisabledattribute and its inner native button stays interactive, whiledisabled={true}disables it.Manual test page (after the branch deploys):