Skip to content

Commit b14a46b

Browse files
committed
chore: update maxCount logic
1 parent 9ff3181 commit b14a46b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/OptionList.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
180180
return false;
181181
}
182182

183+
console.log('--->', node);
184+
183185
if (leftMaxCount === null) {
184186
return false;
185187
}

src/TreeSelect.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,17 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
408408

409409
const [cachedDisplayValues] = useCache(displayValues);
410410

411+
// ========================== MaxCount ==========================
412+
const mergedMaxCount = React.useMemo(() => {
413+
if (
414+
mergedMultiple &&
415+
(mergedShowCheckedStrategy === 'SHOW_CHILD' || treeCheckStrictly || !treeCheckable)
416+
) {
417+
return maxCount;
418+
}
419+
return null;
420+
}, [maxCount, mergedMultiple, treeCheckStrictly, mergedShowCheckedStrategy, treeCheckable]);
421+
411422
// =========================== Change ===========================
412423
const triggerChange = useRefFunc(
413424
(
@@ -423,7 +434,7 @@ const TreeSelect = React.forwardRef<BaseSelectRef, TreeSelectProps>((props, ref)
423434
);
424435

425436
// Not allow pass with `maxCount`
426-
if (maxCount && formattedKeyList.length > maxCount) {
437+
if (mergedMaxCount && formattedKeyList.length > mergedMaxCount) {
427438
return;
428439
}
429440

0 commit comments

Comments
 (0)