Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/components/tree/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ import type { TdTreeProps, TreeInstanceFunctions } from './type';
export type TreeProps = TdTreeProps & StyledProps;

const Tree = forwardRef<TreeInstanceFunctions<TreeOptionData>, TreeProps>((originalProps, ref) => {
const { treeClassNames, transitionNames, transitionClassNames, transitionDuration, locale } = useTreeConfig();

const { value, onChange, expanded, onExpand, onActive, actived, setTreeIndeterminate, indeterminate } =
useControllable(originalProps);
const props = useDefaultProps<TreeProps>(originalProps, treeDefaultProps);
Expand All @@ -66,6 +64,9 @@ const Tree = forwardRef<TreeInstanceFunctions<TreeOptionData>, TreeProps>((origi
onScroll,
} = props;

const { treeClassNames, transitionNames, transitionClassNames, transitionDuration, locale } =
useTreeConfig(transition);

// 可见节点集合
const [visibleNodes, setVisibleNodes] = useState([]);

Expand Down
7 changes: 4 additions & 3 deletions packages/components/tree/hooks/useTreeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMemo } from 'react';
import useConfig from '../../hooks/useConfig';
import { useLocaleReceiver } from '../../locale/LocalReceiver';

export function useTreeConfig() {
export function useTreeConfig(transition = true) {
const { classPrefix: prefix } = useConfig();
const [locale, t] = useLocaleReceiver('tree');

Expand Down Expand Up @@ -63,8 +63,9 @@ export function useTreeConfig() {
treeClassNames,
transitionNames,
transitionClassNames,
transitionDuration: 300,
// transition 关闭时立即移除节点,避免 CSSTransition 多等 300ms 造成的关闭延迟
transitionDuration: transition ? 300 : 0,
locale: (key) => t(locale[key]),
};
}, [locale, prefix, t]);
}, [locale, prefix, t, transition]);
}
6 changes: 6 additions & 0 deletions packages/tdesign-react/.changelog/pr-4231.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
pr_number: 4231
contributor: uyarn
---

- fix(Tree): 修复关闭 `transition` API 后,由于内部 duration 没有移除导致出现的卡顿表现 @uyarn ([#4231](https://github.com/Tencent/tdesign-react/pull/4231))
Loading