Browse Source

chore: adjust parameter order (#40256)

pull/40267/head
lijianan 2 years ago
committed by GitHub
parent
commit
1f201d5cc9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      components/tree-select/index.tsx
  2. 2
      components/tree/Tree.tsx
  3. 8
      components/tree/__tests__/util.test.tsx
  4. 2
      components/tree/utils/iconUtil.tsx

2
components/tree-select/index.tsx

@ -222,7 +222,7 @@ const InternalTreeSelect = <OptionType extends BaseOptionType | DefaultOptionTyp
removeIcon={removeIcon}
clearIcon={clearIcon}
switcherIcon={(nodeProps: AntTreeNodeProps) =>
renderSwitcherIcon(treePrefixCls, switcherIcon, treeLine, nodeProps)
renderSwitcherIcon(treePrefixCls, switcherIcon, nodeProps, treeLine)
}
showTreeIcon={treeIcon as any}
notFoundContent={mergedNotFound}

2
components/tree/Tree.tsx

@ -239,7 +239,7 @@ const Tree = React.forwardRef<RcTree, TreeProps>((props, ref) => {
checkable={checkable ? <span className={`${prefixCls}-checkbox-inner`} /> : checkable}
selectable={selectable}
switcherIcon={(nodeProps: AntTreeNodeProps) =>
renderSwitcherIcon(prefixCls, switcherIcon, showLine, nodeProps)
renderSwitcherIcon(prefixCls, switcherIcon, nodeProps, showLine)
}
draggable={draggableConfig}
>

8
components/tree/__tests__/util.test.tsx

@ -51,7 +51,7 @@ describe('Tree util', () => {
it('returns a loading icon when loading', () => {
const { container } = render(
<>{renderSwitcherIcon(prefixCls, undefined, true, { loading: true })}</>,
<>{renderSwitcherIcon(prefixCls, undefined, { loading: true }, true)}</>,
);
expect(container.getElementsByClassName(`${prefixCls}-switcher-loading-icon`)).toHaveLength(
1,
@ -60,7 +60,7 @@ describe('Tree util', () => {
it('returns nothing when node is a leaf without showLine', () => {
const { container } = render(
<>{renderSwitcherIcon(prefixCls, undefined, false, { loading: false, isLeaf: true })}</>,
<>{renderSwitcherIcon(prefixCls, undefined, { loading: false, isLeaf: true }, false)}</>,
);
expect(container).toBeEmptyDOMElement();
});
@ -73,8 +73,8 @@ describe('Tree util', () => {
{renderSwitcherIcon(
prefixCls,
undefined,
{ showLeafIcon: customLeafIcon },
{ loading: false, isLeaf: true },
{ showLeafIcon: customLeafIcon },
)}
</>,
);
@ -94,8 +94,8 @@ describe('Tree util', () => {
{renderSwitcherIcon(
prefixCls,
undefined,
{ showLeafIcon },
{ loading: false, isLeaf: true },
{ showLeafIcon },
)}
</>,
);

2
components/tree/utils/iconUtil.tsx

@ -11,8 +11,8 @@ import type { AntTreeNodeProps, TreeLeafIcon, SwitcherIcon } from '../Tree';
export default function renderSwitcherIcon(
prefixCls: string,
switcherIcon: SwitcherIcon,
showLine: boolean | { showLeafIcon: boolean | TreeLeafIcon } | undefined,
treeNodeProps: AntTreeNodeProps,
showLine?: boolean | { showLeafIcon: boolean | TreeLeafIcon },
): React.ReactNode {
const { isLeaf, expanded, loading } = treeNodeProps;

Loading…
Cancel
Save