diff --git a/packages/core/src/components/RadioButton/RadioButton.tsx b/packages/core/src/components/RadioButton/RadioButton.tsx index a845dd55bf..b4405ed854 100644 --- a/packages/core/src/components/RadioButton/RadioButton.tsx +++ b/packages/core/src/components/RadioButton/RadioButton.tsx @@ -27,6 +27,8 @@ export interface RadioButtonProps extends VibeComponentProps { value?: string; /** A string specifying a name for the input control. This name is submitted along with the control's value when the form data is submitted. */ name?: string; + /** is autoFocus */ + autoFocus?: boolean; /** is disabled */ disabled?: boolean; /** why the input is disabled */ @@ -64,6 +66,7 @@ const RadioButton: VibeComponent & object = forwa */ radioButtonClassName, disabled = false, + autoFocus, disabledReason, defaultChecked = false, children, @@ -80,6 +83,7 @@ const RadioButton: VibeComponent & object = forwa const inputRef = useRef(); const mergedRef = useMergeRef(ref, inputRef); const overrideClassName = backwardCompatibilityForProperties([className, componentClassName]); + const onChildClick = useCallback(() => { if (disabled || !retainChildClick) return; if (inputRef.current) { @@ -114,6 +118,7 @@ const RadioButton: VibeComponent & object = forwa type="radio" value={value} name={name} + autoFocus={autoFocus} disabled={disabled} {...checkedProps} onChange={onSelect} diff --git a/packages/core/src/components/RadioButton/__tests__/__snapshots__/radioButton-snapshot-tests.jest.tsx.snap b/packages/core/src/components/RadioButton/__tests__/__snapshots__/radioButton-snapshot-tests.jest.tsx.snap index afbe409e9c..44d8af9e62 100644 --- a/packages/core/src/components/RadioButton/__tests__/__snapshots__/radioButton-snapshot-tests.jest.tsx.snap +++ b/packages/core/src/components/RadioButton/__tests__/__snapshots__/radioButton-snapshot-tests.jest.tsx.snap @@ -1,5 +1,31 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`RadioButton renders correctly when autoFocus 1`] = ` + +`; + exports[`RadioButton renders correctly when checked 1`] = `