Skip to content

Commit 7d3d120

Browse files
fix: Switch inputProps
1 parent 4620e37 commit 7d3d120

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

packages/@primereact/headless/src/switch/useSwitch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const useSwitch = withHeadless({
4040
type: 'checkbox' as const,
4141
role: 'switch' as const,
4242
checked: checkedState,
43+
disabled: props.disabled,
4344
'aria-checked': checkedState,
4445
...(props.invalid && { 'aria-invalid': true as const }),
4546
...(props.tabIndex !== undefined && { tabIndex: props.tabIndex }),

packages/primereact/src/switch/root/SwitchRoot.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,7 @@ export const SwitchRoot = withComponent({
2020

2121
const switchHook = useSwitch(useSwitchButtonProps);
2222

23-
const inputElementProps = {
24-
id: props.inputId,
25-
disabled: props.disabled
26-
};
27-
28-
return { ...switchHook, inputElementProps };
23+
return switchHook;
2924
},
3025
render(instance) {
3126
const {
@@ -37,15 +32,14 @@ export const SwitchRoot = withComponent({
3732
sx,
3833
// prop getters
3934
rootProps: headlessRootProps,
40-
inputProps: hookInputProps,
41-
inputElementProps
35+
inputProps: hookInputProps
4236
} = instance;
4337

4438
const createInputElement = () => {
4539
const inputProps = mergeProps(
4640
hookInputProps,
47-
inputElementProps,
4841
{
42+
id: props.inputId,
4943
className: cn(cx('input'), props.inputClassName),
5044
style: props.inputStyle
5145
},

0 commit comments

Comments
 (0)