feat(Tree): disable Tree when Form is disabled

This commit is contained in:
zhangming 2023-11-23 15:00:04 +08:00
parent b34259ca1c
commit 881b056c87

View File

@ -6,6 +6,7 @@ import type { CSSMotionProps } from 'rc-motion';
import type { BasicDataNode, TreeProps as RcTreeProps } from 'rc-tree';
import RcTree from 'rc-tree';
import type { DataNode, Key } from 'rc-tree/lib/interface';
import DisabledContext from '../config-provider/DisabledContext';
import initCollapseMotion from '../_util/motion';
import { ConfigContext } from '../config-provider';
@ -172,11 +173,16 @@ const Tree = React.forwardRef<RcTree, TreeProps>((props, ref) => {
draggable,
motion: customMotion,
style,
disabled: customDisabled,
} = props;
const prefixCls = getPrefixCls('tree', customizePrefixCls);
const rootPrefixCls = getPrefixCls();
// ===================== Disabled =====================
const disabled = React.useContext(DisabledContext);
const mergedDisabled = customDisabled ?? disabled;
const motion: CSSMotionProps = customMotion ?? {
...initCollapseMotion(rootPrefixCls),
motionAppear: false,
@ -191,6 +197,7 @@ const Tree = React.forwardRef<RcTree, TreeProps>((props, ref) => {
blockNode,
showLine: Boolean(showLine),
dropIndicatorRender,
disabled: mergedDisabled,
};
const [wrapSSR, hashId] = useStyle(prefixCls);