diff --git a/src/OptionList.tsx b/src/OptionList.tsx index ec07eb67..b5ab3da2 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -124,10 +124,26 @@ const OptionList: React.ForwardRefRenderFunction = (_, r // https://github.com/ant-design/ant-design/issues/34975 const isSelected = React.useCallback( - (value: RawValueType) => rawValues.has(value) && mode !== 'combobox', + (value: RawValueType) => { + if (mode === 'combobox') { + return false; + } + return rawValues.has(value); + }, [mode, [...rawValues].toString(), rawValues.size], ); + // https://github.com/ant-design/ant-design/issues/48036 + const isAriaSelected = React.useCallback( + (value: RawValueType) => { + if (mode === 'combobox') { + return String(value).toLowerCase() === searchValue.toLowerCase(); + } + return rawValues.has(value); + }, + [mode, searchValue, [...rawValues].toString(), rawValues.size], + ); + // Auto scroll to item position in single mode useEffect(() => { /** @@ -275,7 +291,7 @@ const OptionList: React.ForwardRefRenderFunction = (_, r {...attrs} key={index} {...getItemAriaProps(item, index)} - aria-selected={isSelected(value)} + aria-selected={isAriaSelected(value)} > {value} @@ -360,7 +376,7 @@ const OptionList: React.ForwardRefRenderFunction = (_, r
{