Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/@react-aria/radio/src/useRadio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: Ref

// Handle press state on the label.
let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({
isDisabled
isDisabled,
onPress() {
state.setSelectedValue(value);
ref.current?.focus();
}
});

let {focusableProps} = useFocusable(mergeProps(props, {
Expand All @@ -94,7 +98,7 @@ export function useRadio(props: AriaRadioProps, state: RadioGroupState, ref: Ref
useFormValidation({validationBehavior}, state, ref);

return {
labelProps,
labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}),
inputProps: mergeProps(domProps, {
...interactions,
type: 'radio',
Expand Down
6 changes: 5 additions & 1 deletion packages/@react-aria/toggle/src/useToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export function useToggle(props: AriaToggleProps, state: ToggleState, ref: RefOb

// Handle press state on the label.
let {pressProps: labelProps, isPressed: isLabelPressed} = usePress({
onPress() {
state.toggle();
ref.current?.focus();
},
isDisabled: isDisabled || isReadOnly
});

Expand All @@ -80,7 +84,7 @@ export function useToggle(props: AriaToggleProps, state: ToggleState, ref: RefOb
useFormReset(ref, state.isSelected, state.setSelected);

return {
labelProps,
labelProps: mergeProps(labelProps, {onClick: e => e.preventDefault()}),
inputProps: mergeProps(domProps, {
'aria-invalid': isInvalid || validationState === 'invalid' || undefined,
'aria-errormessage': props['aria-errormessage'],
Expand Down