From b0c608e07c7e9b3852f84005642afa5379947e1a Mon Sep 17 00:00:00 2001 From: xiamiao Date: Tue, 23 Apr 2024 11:40:40 +0800 Subject: [PATCH 1/3] =?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)} From 613c15a41d783b86d86ccfb1dccd4da897e5ba9c Mon Sep 17 00:00:00 2001 From: xiamiao Date: Tue, 23 Apr 2024 11:43:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?chore(select):=20=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E8=AE=B0=E5=BD=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/real-keys-check.md | 5 +++++ .changeset/tough-kangaroos-beam.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/real-keys-check.md create mode 100644 .changeset/tough-kangaroos-beam.md diff --git a/.changeset/real-keys-check.md b/.changeset/real-keys-check.md new file mode 100644 index 000000000..c33995b8c --- /dev/null +++ b/.changeset/real-keys-check.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/select": patch +--- + +fix: 修复搜索时在中文输入法下按回车键弹窗会关闭的问题 diff --git a/.changeset/tough-kangaroos-beam.md b/.changeset/tough-kangaroos-beam.md new file mode 100644 index 000000000..db7cba9d7 --- /dev/null +++ b/.changeset/tough-kangaroos-beam.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +fix(select): 修复搜索时在中文输入法下按回车键弹窗会关闭的问题 From 99c8d84a500a6a857adb1921addb4b278b255168 Mon Sep 17 00:00:00 2001 From: xiamiao Date: Thu, 9 May 2024 11:32:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore(select):=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E7=AE=80=E5=8C=96(#2809)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/select/src/Select.tsx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/ui/select/src/Select.tsx b/packages/ui/select/src/Select.tsx index de4d8ac00..94f355e96 100644 --- a/packages/ui/select/src/Select.tsx +++ b/packages/ui/select/src/Select.tsx @@ -186,12 +186,11 @@ 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 + const { keyCode } = evt - if (key === 'Enter' && !isComposing) { + if (keyCode === 13) { const item = showData[focusedIndex] if (item) { @@ -236,12 +235,6 @@ 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)}