fix(core): forward rest props (data-testid) to CheckboxInput's native input#3738
Open
let-sunny wants to merge 1 commit into
Open
fix(core): forward rest props (data-testid) to CheckboxInput's native input#3738let-sunny wants to merge 1 commit into
let-sunny wants to merge 1 commit into
Conversation
… input CheckboxInput used a closed destructuring list with no ...rest capture, so any prop not explicitly named was silently dropped despite CheckboxInputProps (via BaseProps) typing data-* attributes as valid. Every sibling input component (TextInput, Selector, Slider, Button, Badge) already forwards rest props; CheckboxInput was the sole outlier (same defect class as facebook#1444, fixed on Selector). Rest is spread before the input's own named attributes, mirroring TextInput's pattern, so it cannot override checked/disabled/type or any other explicitly-set prop.
|
@let-sunny is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
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.
Summary
CheckboxInputacceptsBaseProps— which explicitly typesdata-*attributes ("telemetry, testing, integration hooks") — but destructures a closed list of named props with no...restcapture, sodata-testidand every other extra attribute is silently dropped and never reaches the DOM.Button,TextInput,Selector,Slider, andBadgeall forward rest props to their root/interactive element;CheckboxInputis the only one of these that doesn't. The API-Conventions wiki statesdata-testidshould "pass through to the primary interactive element".This is the same defect class as #1415 (
Selectornot forwarding extraBasePropsattributes), which was fixed in #1444 with exactly this rest-spread pattern — this PR applies that established fix toCheckboxInput.Change
CheckboxInput.tsx: capture...restin the destructure and spread it onto the native<input type="checkbox">before the component's own named attributes, sorestcan never clobberchecked/disabled/type— mirroringTextInput's existing pattern.doc.mjschange:docPropReferences.test.tsexemptsdata-testid/className/style/xstyle/refas universal props not listed per component (verified againstTextInput.doc.mjs).Verification
data-testidlands on the input; arbitrarydata-*lands; rest props cannot overridechecked/disabled/type.getByTestIdfinds nothing / attributenull); all 31 tests in the file pass with the fix.pnpm --filter @astryxdesign/core typecheckclean; eslint clean on touched files; repo pre-commit checks (sync/package-boundaries/changesets/demo-media) all pass.@astryxdesign/corepatch.Repro (pre-fix, published @astryxdesign/core@0.1.3 and current main)