From b0c608e07c7e9b3852f84005642afa5379947e1a Mon Sep 17 00:00:00 2001 From: xiamiao Date: Tue, 23 Apr 2024 11:40:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(select):=20=E4=BF=AE=E5=A4=8D=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=97=B6=E5=9C=A8=E4=B8=AD=E6=96=87=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=B3=95=E4=B8=8B=E6=8C=89=E5=9B=9E=E8=BD=A6=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E4=BC=9A=E5=85=B3=E9=97=AD=E7=9A=84=E9=97=AE=E9=A2=98(#2809)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/select/src/Select.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/ui/select/src/Select.tsx b/packages/ui/select/src/Select.tsx index 1e5379334..de4d8ac00 100644 --- a/packages/ui/select/src/Select.tsx +++ b/packages/ui/select/src/Select.tsx @@ -186,11 +186,12 @@ export const Select = forwardRef( const defaultIndex = showData.findIndex((item: SelectDataItem) => !item.disabled) const [focusedIndex, setFocusedIndex] = useState(defaultIndex) + const [isComposing, setIsComposing] = useState(false) const handleKeyDown = useLatestCallback((evt: React.KeyboardEvent) => { const { key } = evt - if (key === 'Enter') { + if (key === 'Enter' && !isComposing) { const item = showData[focusedIndex] if (item) { @@ -235,6 +236,12 @@ export const Select = forwardRef( onKeyDown={mockDefaultHandlers(handleKeyDown, onKeyDownProp)} onOpen={menuVisibleAction.on} onClose={menuVisibleAction.off} + onCompositionStart={() => { + setIsComposing(true) + }} + onCompositionEnd={() => { + setIsComposing(false) + }} searchable={searchable} keyword={keywordProp} onSearch={callAllFuncs(onSearchProp, onSearch)}