Repository navigation
[switch] Add value prop - #3676
Conversation
Add 'value' prop to SwitchRoot component for form submission. Signed-off-by: Jonathan <[email protected]>
commit: |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thanks for the contribution - I've linked the issue: #3410 I'm not sure it's this simple though: Checkbox has a // React <19 sets an empty value if `undefined` is passed explicitly
// To avoid this, we only set the value if it's defined
valueProp !== undefined
? { value: (groupContext ? checked && valueProp : valueProp) || '' }
: EMPTY_OBJECT,Tests would be good in any case though |
|
@atomiks thanks, I added the same logic as the checkbox and added a test |
Signed-off-by: atomiks <[email protected]>
Signed-off-by: atomiks <[email protected]>
| /** | ||
| * The value submitted with the form when the switch is on. | ||
| * By default, switches submit the value "on", matching native checkbox behavior. | ||
| */ | ||
| value?: string; |
There was a problem hiding this comment.
pnpm docs:api needs to be ran to generate the docs for this prop
There are also some lint errors to address
Bundle size report
Check out the code infra dashboard for more information about this PR. |
LukasTy
left a comment
There was a problem hiding this comment.
Thank you for the contribution. 🙏
As James said, please run pnpm prettier && pnpm doc:api.
value prop
Signed-off-by: Lukas Tyla <[email protected]>
LukasTy
left a comment
There was a problem hiding this comment.
LGTM. 👍
Adding comments to adjust the test, such that it doesn't break on React <19.
Signed-off-by: Lukas Tyla <[email protected]>
Signed-off-by: atomiks <[email protected]>
Signed-off-by: atomiks <[email protected]>
Signed-off-by: atomiks <[email protected]>
Add 'value' prop to SwitchRoot component for form submission. For instance in a project i'm working on I want the value "1" or "0".
Closes #3410