From cd26e7cf7b666da211efc7dd7af4f58a25a1b7a0 Mon Sep 17 00:00:00 2001 From: chensara Date: Thu, 11 Apr 2024 11:10:08 +0300 Subject: [PATCH] feat: add autoFocus to CheckBox (#2059) Co-authored-by: Yossi Saadi --- .../core/src/components/Checkbox/Checkbox.tsx | 4 + .../checkbox-snapshot-tests.jest.tsx.snap | 47 +++++++++++ .../checkbox-snapshot-tests.jest.tsx | 5 ++ .../__tests__/checkbox-tests.jest.tsx | 80 ++++++++++++++----- 4 files changed, 115 insertions(+), 21 deletions(-) diff --git a/packages/core/src/components/Checkbox/Checkbox.tsx b/packages/core/src/components/Checkbox/Checkbox.tsx index b1954d63ac..9836f9bc6e 100644 --- a/packages/core/src/components/Checkbox/Checkbox.tsx +++ b/packages/core/src/components/Checkbox/Checkbox.tsx @@ -36,6 +36,8 @@ export interface CheckBoxProps extends VibeComponentProps { checked?: boolean; /** An in between state to display a non selected */ indeterminate?: boolean; + /** is autoFocus */ + autoFocus?: boolean; /** Set the option to be disabled */ disabled?: boolean; /** the default value which the checkbox will start from */ @@ -63,6 +65,7 @@ const Checkbox: VibeComponent = forwardRef( ariaLabelledBy, onChange = NOOP, checked, + autoFocus, indeterminate = false, disabled = false, defaultChecked, @@ -127,6 +130,7 @@ const Checkbox: VibeComponent = forwardRef( value={value} name={name} type="checkbox" + autoFocus={autoFocus} onChange={onChange} defaultChecked={overrideDefaultChecked} disabled={disabled} diff --git a/packages/core/src/components/Checkbox/__tests__/__snapshots__/checkbox-snapshot-tests.jest.tsx.snap b/packages/core/src/components/Checkbox/__tests__/__snapshots__/checkbox-snapshot-tests.jest.tsx.snap index c3d6b4bd7f..49a900db2a 100644 --- a/packages/core/src/components/Checkbox/__tests__/__snapshots__/checkbox-snapshot-tests.jest.tsx.snap +++ b/packages/core/src/components/Checkbox/__tests__/__snapshots__/checkbox-snapshot-tests.jest.tsx.snap @@ -1,5 +1,52 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Checkbox renders correctly when autoFocus 1`] = ` + +`; + exports[`Checkbox renders correctly when checked 1`] = `