@@ -36,8 +36,17 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP
36
36
_ ,
37
37
ref ,
38
38
) => {
39
- const { prefixCls, id, open, multiple, searchValue, toggleOpen, notFoundContent, onPopupScroll } =
40
- useBaseProps ( ) ;
39
+ const {
40
+ prefixCls,
41
+ id,
42
+ open,
43
+ multiple,
44
+ mode,
45
+ searchValue,
46
+ toggleOpen,
47
+ notFoundContent,
48
+ onPopupScroll,
49
+ } = useBaseProps ( ) ;
41
50
const {
42
51
flattenOptions,
43
52
onActiveValue,
@@ -108,6 +117,12 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP
108
117
setActive ( defaultActiveFirstOption !== false ? getEnabledActiveIndex ( 0 ) : - 1 ) ;
109
118
} , [ memoFlattenOptions . length , searchValue ] ) ;
110
119
120
+ // https://github.com/ant-design/ant-design/issues/34975
121
+ const isSelected = React . useCallback (
122
+ ( value : RawValueType ) => rawValues . has ( value ) && mode !== 'combobox' ,
123
+ [ mode , [ ...rawValues ] . toString ( ) ] ,
124
+ ) ;
125
+
111
126
// Auto scroll to item position in single mode
112
127
useEffect ( ( ) => {
113
128
/**
@@ -246,7 +261,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP
246
261
key = { index }
247
262
role = { group ? 'presentation' : 'option' }
248
263
id = { `${ id } _list_${ index } ` }
249
- aria-selected = { rawValues . has ( value ) }
264
+ aria-selected = { isSelected ( value ) }
250
265
>
251
266
{ value }
252
267
</ div >
@@ -293,7 +308,7 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, OptionListP
293
308
const passedProps = omit ( otherProps , omitFieldNameList ) ;
294
309
295
310
// Option
296
- const selected = rawValues . has ( value ) ;
311
+ const selected = isSelected ( value ) ;
297
312
298
313
const optionPrefixCls = `${ itemPrefixCls } -option` ;
299
314
const optionClassName = classNames ( itemPrefixCls , optionPrefixCls , className , {
0 commit comments