feat(text-input)!: port to <pf-v6-text-input> - #3160
Conversation
🦋 Changeset detectedLatest commit: 99ff953 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for patternfly-elements ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Commitlint tests passed!More Info{
"valid": true,
"errors": [],
"warnings": [],
"input": "feat(text-input)!: port to `<pf-v6-text-input>`"
} |
adamjohnson
left a comment
There was a problem hiding this comment.
- Would recommend running a Claude code review on this PR since Qodo is not enabled (?) for this repo.
- I see some things flagged around validity,
preventDefault()onchange, andformResetCallbackalways clearing to''.
- I see some things flagged around validity,
- The addition of reference target is a nice look forward, but, currently, has zero browser support and is still in development. I could see arguments to not include this functionality with this PR, even though we want it bad. It may be better suited for a follow up.
| --- | ||
| <form id="text-input-form"> | ||
| <label for="input">Name</label> | ||
| <pf-v6-text-input id="input" name="username" required></pf-v6-text-input> |
There was a problem hiding this comment.
The required attribute here does not block form submit. FACE validity stays valid until something calls checkValidity().
|
|
||
| #renderStatusIcon(): TemplateResult<1> | string { | ||
| if (this.#isInvalid && this.validated !== 'error') { | ||
| return html`<svg role="presentation" fill="currentColor" height="1em" width="1em" viewBox="0 0 512 512"><path d="M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"/></svg>`; |
There was a problem hiding this comment.
I'd prefer to see aria-hidden="true" here in place of role="presentation" just to make sure these SVGs are really hidden from AT. Here's more info on this hidden vs presentation stance.
Be sure to do it here and elsewhere in this PR (demos).
| <fieldset> | ||
| <legend>Invalid</legend> | ||
| <pf-v6-text-input id="invalid-input" | ||
| validated="error" |
There was a problem hiding this comment.
Our buddy Claude is saying this state is "visual only" and constraint validation never ran, so there's nothing to announce ala #status-message. Double check on that.
I would also consider renaming the <legend> to something like "Snowboards" so that, when using AT, we don't get confused when it might announce "invalid, text input, invalid" or something similar.
Also, do you think validated="error" is a necessary attribute? aria-invalid maps directly to the HTML required attribute. Is this being added so that users could intercept manually and display this state?
| </span> | ||
| <span id="status-message" | ||
| role="${ifDefined(this.#isInvalid ? 'alert' : undefined)}" | ||
| aria-live="${ifDefined(this.#isInvalid ? 'assertive' : undefined)}" |
There was a problem hiding this comment.
Since the line above sets role="alert", you do not need the aria-live="assertive" here. Source.
What I did
<pf-v5-text-input><pf-v5-text-input>to<pf-v6-text-input>web component for PatternFly v6typevariants, validation states, and custom icon supportElementInternals, supports form reset, constraint validation (checkValidity(),reportValidity(),setCustomValidity())referenceTarget: when available, external<label for>andaria-describedbyresolve natively through the shadow boundarydelegatesFocus+computedLabelTextstring copy (same mechanism as v5)role="alert"+aria-describedbyon the internal input--pf-v6-c-form-control--*,--pf-t--global--*) withlight-dark()fallbacks::before/::afterpseudo-elements for border styling (matching v6 SCSS structure)classMapinstead of:host([attr])selectorschangeevent: callpreventDefault()to reject a value change<label for="id">oraccessible-labelattributeInternalsController fix (pfe-core)
form,validationMessage, andwillValidategetters onInternalsControllerdeclare-only (TypeScript type annotations with no runtime implementation) since the dynamic proxy was removed in feat: listbox elements #2570pf-v6-text-inputfor Enter-to-submit (form?.requestSubmit()) and error message rendering (validationMessage)Closes #3043
Intentional divergences from React
customIconprop replaced byiconslot (slotted content for composability)isDisabled/isRequiredrenamed todisabled/required(nois-prefix per web component convention)isStartTruncatedreplaced bytruncated="start"enum attribute for future extensibilityreadOnlyVariantsplit intoreadonly+plainattributes (native HTMLreadonly+ visual modifier)isExpanded/expandedPropsnot implemented (combobox patterns will be handled by a dedicated composite element)onChangecallback replaced by cancelablechangeDOM eventvalidated="default"state represented by attribute absenceinnerRef+.select()replaced byselect()method directly on the elementTesting Instructions
Notes to Reviewers