Skip to content

Commit a1da393

Browse files
committed
Feat: support 'expandAction' prop for TreeSelect
1 parent ddc4ce0 commit a1da393

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"@babel/runtime": "^7.10.1",
7070
"classnames": "2.x",
7171
"rc-select": "~14.1.0",
72-
"rc-tree": "~5.5.0",
72+
"rc-tree": "~5.6.1",
7373
"rc-util": "^5.16.1"
7474
}
7575
}

src/OptionList.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const OptionList: React.RefForwardingComponent<ReviseRefOptionListProps> = (_, r
4141
fieldNames,
4242
onSelect,
4343
dropdownMatchSelectWidth,
44+
expandAction,
4445
} = React.useContext(TreeSelectContext);
4546

4647
const {
@@ -244,6 +245,7 @@ const OptionList: React.RefForwardingComponent<ReviseRefOptionListProps> = (_, r
244245
onExpand={onInternalExpand}
245246
onLoad={onTreeLoad}
246247
filterTreeNode={filterTreeNode}
248+
expandAction={expandAction}
247249
/>
248250
</div>
249251
);

src/TreeSelect.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import { BaseSelect } from 'rc-select';
33
import type { IconType } from 'rc-tree/lib/interface';
4+
import type { ExpandAction } from 'rc-tree/lib/Tree';
45
import type {
56
BaseSelectRef,
67
BaseSelectPropsWithoutPrivate,
@@ -152,6 +153,7 @@ export interface TreeSelectProps<
152153
treeExpandedKeys?: React.Key[];
153154
treeDefaultExpandedKeys?: React.Key[];
154155
onTreeExpand?: (expandedKeys: React.Key[]) => void;
156+
expandAction: ExpandAction;
155157

156158
// >>> Options
157159
virtual?: boolean;
@@ -217,6 +219,7 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
217219
treeExpandedKeys,
218220
treeDefaultExpandedKeys,
219221
onTreeExpand,
222+
expandAction,
220223

221224
// Options
222225
virtual,
@@ -647,6 +650,7 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
647650
treeData: filteredTreeData,
648651
fieldNames: mergedFieldNames,
649652
onSelect: onOptionSelect,
653+
expandAction,
650654
}),
651655
[
652656
virtual,
@@ -656,6 +660,7 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
656660
filteredTreeData,
657661
mergedFieldNames,
658662
onOptionSelect,
663+
expandAction,
659664
],
660665
);
661666

src/TreeSelectContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from 'react';
2+
import type { ExpandAction } from 'rc-tree/lib/Tree';
23
import type { DefaultOptionType, InternalFieldName, OnInternalSelect } from './TreeSelect';
34

45
export interface TreeSelectContextProps {
@@ -9,6 +10,7 @@ export interface TreeSelectContextProps {
910
treeData: DefaultOptionType[];
1011
fieldNames: InternalFieldName;
1112
onSelect: OnInternalSelect;
13+
expandAction: ExpandAction;
1214
}
1315

1416
const TreeSelectContext = React.createContext<TreeSelectContextProps>(null as any);

0 commit comments

Comments
 (0)