Skip to content

Commit a5625a1

Browse files
committed
refactor: reuse formatStrategyValues
1 parent ff9f216 commit a5625a1

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/OptionList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
151151

152152
React.useEffect(() => {
153153
if (searchValue) {
154-
setSearchExpandedKeys(getAllKeys(treeData, fieldNames));
154+
setSearchExpandedKeys(getAllKeys(memoTreeData, fieldNames));
155155
}
156156
// eslint-disable-next-line react-hooks/exhaustive-deps
157157
}, [searchValue]);

src/TreeSelect.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -415,15 +415,15 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
415415
extra: { triggerValue?: SafeKey; selected?: boolean },
416416
source: SelectSource,
417417
) => {
418+
const formattedKeyList = formatStrategyValues(
419+
newRawValues,
420+
mergedShowCheckedStrategy,
421+
keyEntities,
422+
mergedFieldNames,
423+
);
424+
418425
// if multiple and maxCount is set, check if exceed maxCount
419426
if (mergedMultiple && maxCount !== undefined) {
420-
const formattedKeyList = formatStrategyValues(
421-
newRawValues,
422-
mergedShowCheckedStrategy,
423-
keyEntities,
424-
mergedFieldNames,
425-
);
426-
427427
if (formattedKeyList.length > maxCount) {
428428
return;
429429
}
@@ -441,12 +441,6 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
441441
if (onChange) {
442442
let eventValues: SafeKey[] = newRawValues;
443443
if (treeConduction) {
444-
const formattedKeyList = formatStrategyValues(
445-
newRawValues,
446-
mergedShowCheckedStrategy,
447-
keyEntities,
448-
mergedFieldNames,
449-
);
450444
eventValues = formattedKeyList.map(key => {
451445
const entity = valueEntities.get(key);
452446
return entity ? entity.node[mergedFieldNames.value] : key;

0 commit comments

Comments
 (0)