Skip to content

Commit b3ef249

Browse files
authored
fix(checkbox): get disabled prop from parent (#6970)
1 parent f953482 commit b3ef249

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

components/checkbox/Checkbox.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import warning from '../_util/warning';
1515
import type { EventHandler } from '../_util/EventInterface';
1616
import { FormItemInputContext, useInjectFormItemContext } from '../form/FormItemContext';
1717
import useConfigInject from '../config-provider/hooks/useConfigInject';
18+
import { useInjectDisabled } from '../config-provider/DisabledContext';
1819

1920
import type { CheckboxChangeEvent, CheckboxProps } from './interface';
2021
import { CheckboxGroupContextKey, checkboxProps } from './interface';
@@ -33,6 +34,8 @@ export default defineComponent({
3334
const formItemContext = useInjectFormItemContext();
3435
const formItemInputContext = FormItemInputContext.useInject();
3536
const { prefixCls, direction, disabled } = useConfigInject('checkbox', props);
37+
38+
const contextDisabled = useInjectDisabled();
3639
// style
3740
const [wrapSSR, hashId] = useStyle(prefixCls);
3841

@@ -94,7 +97,7 @@ export default defineComponent({
9497
};
9598
checkboxProps.name = checkboxGroup.name.value;
9699
checkboxProps.checked = checkboxGroup.mergedValue.value.includes(props.value);
97-
checkboxProps.disabled = mergedDisabled.value || checkboxGroup.disabled.value;
100+
checkboxProps.disabled = mergedDisabled.value || contextDisabled.value;
98101
checkboxProps.indeterminate = indeterminate;
99102
} else {
100103
checkboxProps.onChange = handleChange;
@@ -129,7 +132,6 @@ export default defineComponent({
129132
{...checkboxProps}
130133
class={checkboxClass}
131134
ref={checkboxRef}
132-
disabled={mergedDisabled.value}
133135
/>
134136
{children.length ? <span>{children}</span> : null}
135137
</label>,

0 commit comments

Comments
 (0)