@@ -82,6 +82,19 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
82
82
[ checkedKeys , maxCount , multiple ] ,
83
83
) ;
84
84
85
+ const traverse = ( nodes : EventDataNode < any > [ ] ) : EventDataNode < any > [ ] => {
86
+ return nodes . map ( node => ( {
87
+ ...node ,
88
+ disabled : isOverMaxCount && ! checkedKeys . includes ( node . key as SafeKey ) ? true : node . disabled ,
89
+ children : node . children ? traverse ( node . children ) : undefined ,
90
+ } ) ) ;
91
+ } ;
92
+
93
+ const processedTreeData = React . useMemo (
94
+ ( ) => traverse ( memoTreeData ) ,
95
+ [ memoTreeData , isOverMaxCount , checkedKeys ] ,
96
+ ) ;
97
+
85
98
// ========================== Active ==========================
86
99
const [ activeKey , setActiveKey ] = React . useState < Key > ( null ) ;
87
100
const activeEntity = keyEntities [ activeKey as SafeKey ] ;
@@ -252,7 +265,7 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
252
265
ref = { treeRef }
253
266
focusable = { false }
254
267
prefixCls = { `${ prefixCls } -tree` }
255
- treeData = { memoTreeData }
268
+ treeData = { processedTreeData }
256
269
height = { listHeight }
257
270
itemHeight = { listItemHeight }
258
271
itemScrollOffset = { listItemScrollOffset }
@@ -279,7 +292,6 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
279
292
onCheck = { onInternalSelect }
280
293
onExpand = { onInternalExpand }
281
294
onLoad = { onTreeLoad }
282
- disabled = { isOverMaxCount }
283
295
filterTreeNode = { filterTreeNode }
284
296
expandAction = { treeExpandAction }
285
297
onScroll = { onPopupScroll }
0 commit comments