fix(pie-wrapper-react): SON-4389 generate controlled-input-aware React wrapper#2958
Open
rikwasmus wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: b0599c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 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 |
f0bad0e to
b0599c2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes (can list changeset entries if preferable)
Problem
@lit/react'screateComponentpushes thevalueprop onto a custom element whenever it changes between renders, but it does not replicate the controlled-input value tracking that ReactDOM applies to native form controls. For input-like components (e.g.pie-text-input, whose inner field renders with Lit'slive(value)directive), a stalevalue— for example while a user is typing and parent state updates are debounced — gets written back to the element and overwrites the user's latest keystroke. Consumers see dropped/“reset” keystrokes when wrapping these components in React.This was surfaced by a catalog search box dropping characters while typing. A native
<input>did not exhibit the issue; the differentiator was the generated PIE React wrapper path.Fix
pie-wrapper-reactnow detects input-like components (those exposing avaluefield and dispatching aninputevent) and generates a controlled-input-aware wrapper for them. The wrapper replicates React's controlled-input contract:valueis no longer forwarded to the underlyingcreateComponentelement; it is managed in the wrapper.valueis only written to the element when the controlled value genuinely changes since it was last applied, so in-flight user input is never clobbered.useLayoutEffectwarning.Non-input components are unchanged and continue to use the existing
createComponentexport (verified: existing wrapper snapshots are byte-identical).Only
pie-text-inputcurrently matches the detection criteria; any future input-like component will pick up the corrected wrapper automatically.Changeset entries
[Added]@justeattakeaway/pie-wrapper-react(minor) — controlled-input-aware wrapper generation.[Fixed]@justeattakeaway/pie-text-input(patch) — React wrapper no longer drops keystrokes whenvaluelags behind user input.Testing
pie-wrapper-reactcovering: controlled wrapper emitted for value+input components, no controlled wrapper for components without aninputevent, and unchanged output for non-input components.pie-text-inputend-to-end (create:manifest→build:react-wrapper→build); the generatedsrc/react.tsand the TypeScript declaration build both succeed.Author Checklist (complete before requesting a review, do not delete any)
Not-applicable Checklist items
Please move any Author checklist items that do not apply to this pull request here.
PIE Storybook/PIE DocsPR preview. — no Storybook/Docs changes in this PR (build-tool + generated wrapper only)./test-aperturecommand. — Aperture is a destructive, once-per-PR maintainer action; this still needs to be run by a maintainer before merge to validate the regenerated wrappers in a real consumer.Reviewer checklists (complete before approving)
Mark items as
[-] N/Aif not applicable.Reviewer 1
PIE Storybook/PIE DocsPR preview.Reviewer 2
PIE Storybook/PIE DocsPR preview.