Skip to content

Commit cc272c4

Browse files
FRSgitSzymon-dziewonski
authored andcommitted
feat: add better data-testid handling to sfCheckbox (#3321)
1 parent e7cc71d commit cc272c4

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

packages/sfui/frameworks/react/components/SfCheckbox/SfCheckbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const defaultWrapperTag = 'label';
1313

1414
const SfCheckbox = polymorphicForwardRef<'input', SfCheckboxProps>(
1515
(
16-
{ wrapperAs, invalid, className, indeterminate: indeterminateProp, wrapperClassName, ...attributes },
16+
{ wrapperAs, invalid, className, indeterminate: indeterminateProp, wrapperClassName, 'data-testid': dataTestId, ...attributes },
1717
ref,
1818
): React.JSX.Element => {
1919
const inputRef = useRef<HTMLInputElement>(null);
@@ -47,7 +47,7 @@ const SfCheckbox = polymorphicForwardRef<'input', SfCheckboxProps>(
4747
},
4848
wrapperClassName,
4949
)}
50-
data-testid="checkbox"
50+
data-testid={dataTestId ?? "checkbox"}
5151
>
5252
<input
5353
className={twMerge('sr-only', className)}

packages/sfui/frameworks/react/components/SfCheckbox/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ export interface SfCheckboxProps extends PropsWithStyle, InputHTMLAttributes<HTM
55
invalid?: boolean;
66
wrapperAs?: ElementType<any> | undefined;
77
wrapperClassName?: string;
8+
'data-testid'?: string;
89
indeterminate?: boolean;
910
}

packages/sfui/frameworks/vue/components/SfCheckbox/SfCheckbox.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ const { indeterminate = false } = defineProps({
2323
default: 'label',
2424
},
2525
wrapperClass: ClassProp,
26+
dataTestid: {
27+
type: String,
28+
default: 'checkbox',
29+
},
2630
});
2731
2832
defineOptions({
@@ -59,7 +63,7 @@ watch(
5963
wrapperClass,
6064
)
6165
"
62-
data-testid="checkbox"
66+
:data-testid="dataTestid ?? 'checkbox'"
6367
>
6468
<input
6569
:class="twMerge('sr-only', $attrs.class)"

0 commit comments

Comments
 (0)