Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 9b9d761

Browse files
committed
feat: add onBlur and onFocus props to Select and Checkbox
1 parent 6ced939 commit 9b9d761

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/components/Checkbox/Checkbox.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ interface InputProps {
1414
checked?: boolean
1515
className?: string
1616
onChange?(x: React.ChangeEvent<HTMLInputElement>): void
17+
onFocus?: any
18+
onBlur?: any
1719
size?: 'tiny' | 'small' | 'medium' | 'large' | 'xlarge'
1820
}
1921

@@ -94,6 +96,8 @@ export function Checkbox({
9496
checked,
9597
value,
9698
onChange,
99+
onFocus,
100+
onBlur,
97101
size = 'medium',
98102
}: InputProps) {
99103
const inputName = name
@@ -140,6 +144,8 @@ export function Checkbox({
140144
type="checkbox"
141145
className={CheckboxStyles['sbui-checkbox']}
142146
onChange={onInputChange}
147+
onFocus={onFocus ? (event) => onFocus(event) : undefined}
148+
onBlur={onBlur ? (event) => onBlur(event) : undefined}
143149
checked={active}
144150
value={value ? value : markupId}
145151
/>

src/components/Select/Select.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export interface Props {
3535
layout?: 'horizontal' | 'vertical'
3636
name?: string
3737
onChange?: any
38+
onFocus?: any
39+
onBlur?: any
3840
placeholder?: string
3941
style?: React.CSSProperties
4042
type?:
@@ -80,6 +82,8 @@ function Select({
8082
layout,
8183
name,
8284
onChange,
85+
onFocus,
86+
onBlur,
8387
placeholder,
8488
required,
8589
value,
@@ -110,7 +114,9 @@ function Select({
110114
autoComplete={autoComplete}
111115
autoFocus={autofocus}
112116
className={selectClasses.join(' ')}
113-
onChange={(event) => onChange(event)}
117+
onChange={onChange ? (event) => onChange(event) : undefined}
118+
onFocus={onFocus ? (event) => onFocus(event) : undefined}
119+
onBlur={onBlur ? (event) => onBlur(event) : undefined}
114120
ref={inputRef}
115121
value={value}
116122
disabled={disabled}

0 commit comments

Comments
 (0)