Repository navigation
Normalize press handling for Checkbox, Radio, and Switch labels - #5525
Conversation
|
Build successful! 🎉 |
snowystinger
left a comment
There was a problem hiding this comment.
LGTM, also, i think you might've solved #3675
There was a problem hiding this comment.
shouldn't we also make the Spectrum components use the labelProps returned by the hooks as well? Probably should update the hooks docs as well to do the same, happy to help with these if you'd like
There was a problem hiding this comment.
yeah but I'm on a tight schedule and not sure I'll have time. mainly wanted this because it was very visible for this demo. seems fine to add to the backlog for RSP if we don't get to it, but if you have time feel free!
There was a problem hiding this comment.
makes sense, I'll see about getting something out for it
There was a problem hiding this comment.
Ah I see, it isn't as trivial as using the labelProps since RSP/hooks example have an actual pressable input (and thus block the press + release on label) element vs RAC which hides it and relies on the label for pointer interactions. I'll file something
|
Build successful! 🎉 |
|
Build successful! 🎉 |
|
Build successful! 🎉 |
243a803
|
Build successful! 🎉 |
|
## API Changes
unknown top level export { type: 'any' } @react-aria/checkboxCheckboxAria CheckboxAria {
inputProps: InputHTMLAttributes<HTMLInputElement>
isDisabled: boolean
isPressed: boolean
isReadOnly: boolean
isSelected: boolean
+ labelProps: LabelHTMLAttributes<HTMLLabelElement>
}it changed:
@react-aria/radioRadioAria RadioAria {
inputProps: InputHTMLAttributes<HTMLInputElement>
isDisabled: boolean
isPressed: boolean
isSelected: boolean
+ labelProps: LabelHTMLAttributes<HTMLLabelElement>
}it changed:
@react-aria/switchSwitchAria SwitchAria {
inputProps: InputHTMLAttributes<HTMLInputElement>
isDisabled: boolean
isPressed: boolean
isReadOnly: boolean
isSelected: boolean
+ labelProps: LabelHTMLAttributes<HTMLLabelElement>
}it changed:
@react-aria/toggleToggleAria ToggleAria {
inputProps: InputHTMLAttributes<HTMLInputElement>
isDisabled: boolean
isInvalid: boolean
isPressed: boolean
isReadOnly: boolean
isSelected: boolean
+ labelProps: LabelHTMLAttributes<HTMLLabelElement>
}it changed:
|
Fixes #3675
Built this animation for the new landing page to show how our press interactions work, but then realized that it didn't work on iOS. Seems like Safari doesn't trigger a click event if you drag off and then back onto the label like it works on desktop.
Switch.Animation2.mov
This adds
labelPropsas a return value touseCheckbox,useRadio, anduseSwitch, which usesusePressto toggle the value and prevents the nativeonClick. This has the side benefit of allowing us to remove the press handling from RAC, which we use for the visible press state. This is not a breaking change: iflabelPropsis unused, it will have no effect.