@@ -48,8 +48,7 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
48
48
treeExpandAction,
49
49
treeTitleRender,
50
50
onPopupScroll,
51
- isOverMaxCount,
52
- maxCount,
51
+ leftMaxCount,
53
52
showCheckedStrategy,
54
53
} = React . useContext ( TreeSelectContext ) ;
55
54
@@ -160,33 +159,19 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
160
159
// eslint-disable-next-line react-hooks/exhaustive-deps
161
160
} , [ searchValue ] ) ;
162
161
163
- const disabledCacheRef = React . useRef ( new Map < Key , boolean > ( ) ) ;
164
- const lastCheckedKeysRef = React . useRef < Key [ ] > ( [ ] ) ;
165
- const lastMaxCountRef = React . useRef < number > ( null ) ;
162
+ // const getSelectableKeys = (targetNode: DataNode, names: FieldNames): Key[] => {
163
+ // const keys = [targetNode[names.value]];
164
+ // if (!Array.isArray(targetNode.children)) {
165
+ // return keys;
166
+ // }
166
167
167
- const resetCache = React . useCallback ( ( ) => {
168
- disabledCacheRef . current . clear ( ) ;
169
- lastCheckedKeysRef . current = [ ...checkedKeys ] ;
170
- lastMaxCountRef . current = maxCount ;
171
- } , [ checkedKeys , maxCount ] ) ;
172
-
173
- React . useEffect ( ( ) => {
174
- resetCache ( ) ;
175
- } , [ checkedKeys , maxCount ] ) ;
176
-
177
- const getSelectableKeys = ( targetNode : DataNode , names : FieldNames ) : Key [ ] => {
178
- const keys = [ targetNode [ names . value ] ] ;
179
- if ( ! Array . isArray ( targetNode . children ) ) {
180
- return keys ;
181
- }
182
-
183
- return targetNode . children . reduce ( ( acc , child ) => {
184
- if ( ! child . disabled ) {
185
- acc . push ( ...getSelectableKeys ( child , names ) ) ;
186
- }
187
- return acc ;
188
- } , keys ) ;
189
- } ;
168
+ // return targetNode.children.reduce((acc, child) => {
169
+ // if (!child.disabled) {
170
+ // acc.push(...getSelectableKeys(child, names));
171
+ // }
172
+ // return acc;
173
+ // }, keys);
174
+ // };
190
175
191
176
const nodeDisabled = useEvent ( ( node : DataNode ) => {
192
177
const nodeValue = node [ fieldNames . value ] ;
@@ -195,33 +180,35 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
195
180
return false ;
196
181
}
197
182
198
- if ( isOverMaxCount ) {
199
- return true ;
183
+ if ( leftMaxCount === null ) {
184
+ return false ;
200
185
}
201
186
202
- const cacheKey = `${ nodeValue } -${ checkedKeys . join ( ',' ) } -${ maxCount } ` ;
187
+ // const cacheKey = `${nodeValue}-${checkedKeys.join(',')}-${maxCount}`;
203
188
204
- // check cache
205
- if ( disabledCacheRef . current . has ( cacheKey ) ) {
206
- return disabledCacheRef . current . get ( cacheKey ) ;
207
- }
189
+ // // check cache
190
+ // if (disabledCacheRef.current.has(cacheKey)) {
191
+ // return disabledCacheRef.current.get(cacheKey);
192
+ // }
208
193
209
- // calculate disabled state
210
- const selectableNodeKeys = getSelectableKeys ( node , fieldNames ) ;
211
- const simulatedCheckedKeys = [ ...checkedKeys , ...selectableNodeKeys ] ;
212
- const simulatedDisplayValues = formatStrategyValues (
213
- simulatedCheckedKeys as SafeKey [ ] ,
214
- showCheckedStrategy ,
215
- keyEntities ,
216
- fieldNames ,
217
- ) ;
194
+ // // calculate disabled state
195
+ // const selectableNodeKeys = getSelectableKeys(node, fieldNames);
196
+ // const simulatedCheckedKeys = [...checkedKeys, ...selectableNodeKeys];
197
+ // const simulatedDisplayValues = formatStrategyValues(
198
+ // simulatedCheckedKeys as SafeKey[],
199
+ // showCheckedStrategy,
200
+ // keyEntities,
201
+ // fieldNames,
202
+ // );
203
+
204
+ // const isDisabled = simulatedDisplayValues.length > maxCount;
218
205
219
- const isDisabled = simulatedDisplayValues . length > maxCount ;
206
+ // // update cache
207
+ // disabledCacheRef.current.set(cacheKey, isDisabled);
220
208
221
- // update cache
222
- disabledCacheRef . current . set ( cacheKey , isDisabled ) ;
209
+ // return isDisabled;
223
210
224
- return isDisabled ;
211
+ return false ;
225
212
} ) ;
226
213
227
214
// ========================== Get First Selectable Node ==========================
0 commit comments