Skip to content

Commit

Permalink
fix: fix itemHeight of Tree (ant-design#46672)
Browse files Browse the repository at this point in the history
* fix: Fix itemHeight of Tree

* fix: Fix itemHeight of Tree
  • Loading branch information
yyz945947732 authored Dec 28, 2023
1 parent a876e8a commit 726e618
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion components/tree/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ConfigContext } from '../config-provider';
import useStyle from './style';
import dropIndicatorRender from './utils/dropIndicator';
import SwitcherIconCom from './utils/iconUtil';
import { useToken } from '../theme/internal';

export type SwitcherIcon = React.ReactNode | ((props: AntTreeNodeProps) => React.ReactNode);
export type TreeLeafIcon = React.ReactNode | ((props: AntTreeNodeProps) => React.ReactNode);
Expand Down Expand Up @@ -194,6 +195,9 @@ const Tree = React.forwardRef<RcTree, TreeProps>((props, ref) => {
};

const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls);
const [, token] = useToken();

const itemHeight = (token.paddingXS / 2) + (token.Tree?.titleHeight || token.controlHeightSM);

const draggableConfig = React.useMemo(() => {
if (!draggable) {
Expand Down Expand Up @@ -231,7 +235,7 @@ const Tree = React.forwardRef<RcTree, TreeProps>((props, ref) => {

return wrapCSSVar(
<RcTree
itemHeight={20}
itemHeight={itemHeight}
ref={ref}
virtual={virtual}
{...newProps}
Expand Down

0 comments on commit 726e618

Please sign in to comment.