@@ -11,6 +11,7 @@ import LegacyContext from './LegacyContext';
11
11
import TreeSelectContext from './TreeSelectContext' ;
12
12
import type { DataNode , Key , SafeKey } from './interface' ;
13
13
import { getAllKeys , isCheckDisabled } from './utils/valueUtil' ;
14
+ import { useEvent } from 'rc-util' ;
14
15
15
16
const HIDDEN_STYLE = {
16
17
width : 0 ,
@@ -79,7 +80,10 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
79
80
( prev , next ) => next [ 0 ] && prev [ 1 ] !== next [ 1 ] ,
80
81
) ;
81
82
82
- const memoDisplayValues = React . useMemo ( ( ) => displayValues ?. map ( v => v . value ) , [ displayValues ] ) ;
83
+ const memoDisplayValues = React . useMemo (
84
+ ( ) => ( displayValues || [ ] ) . map ( v => v . value ) ,
85
+ [ displayValues ] ,
86
+ ) ;
83
87
84
88
// ========================== Values ==========================
85
89
const mergedCheckedKeys = React . useMemo ( ( ) => {
@@ -154,21 +158,17 @@ const OptionList: React.ForwardRefRenderFunction<ReviseRefOptionListProps> = (_,
154
158
155
159
React . useEffect ( ( ) => {
156
160
if ( searchValue ) {
157
- setSearchExpandedKeys ( getAllKeys ( memoTreeData , fieldNames ) ) ;
161
+ setSearchExpandedKeys ( getAllKeys ( treeData , fieldNames ) ) ;
158
162
}
159
163
// eslint-disable-next-line react-hooks/exhaustive-deps
160
164
} , [ searchValue ] ) ;
161
165
162
- const nodeDisabled = ( node : DataNode ) => {
163
- if ( isOverMaxCount ) {
164
- const selectedValues = memoDisplayValues ;
165
- if ( ! selectedValues . includes ( node [ fieldNames . value ] ) ) {
166
- return true ;
167
- }
166
+ const nodeDisabled = useEvent ( ( node : DataNode ) => {
167
+ if ( isOverMaxCount && ! memoDisplayValues . includes ( node [ fieldNames . value ] ) ) {
168
+ return true ;
168
169
}
169
-
170
- return undefined ;
171
- } ;
170
+ return false ;
171
+ } ) ;
172
172
173
173
// ========================== Get First Selectable Node ==========================
174
174
const getFirstMatchingNode = ( nodes : EventDataNode < any > [ ] ) : EventDataNode < any > | null => {
0 commit comments