From 657d1802ac424e2498f9036047cc74a34659d5d6 Mon Sep 17 00:00:00 2001 From: xiamiao1121 <74885998+xiamiao1121@users.noreply.github.com> Date: Thu, 15 Aug 2024 16:48:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(check-select):=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=9B=9E=E8=BD=A6=E9=94=AE=E4=B8=8D=E9=BB=98=E8=AE=A4=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E5=8A=9F=E8=83=BD(#2969)=20(#2970)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(check-select): 支持回车键不默认选中功能(#2969) * chore(check-select): 生成变更记录文件 * chore: update name --------- Co-authored-by: xiamiao --- .changeset/eighty-kids-rest.md | 5 +++++ .changeset/yellow-plums-boil.md | 5 +++++ packages/ui/check-select/src/CheckSelect.tsx | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .changeset/eighty-kids-rest.md create mode 100644 .changeset/yellow-plums-boil.md diff --git a/.changeset/eighty-kids-rest.md b/.changeset/eighty-kids-rest.md new file mode 100644 index 000000000..a8d1d5fae --- /dev/null +++ b/.changeset/eighty-kids-rest.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +feat(check-select): 支持按 Enter 键是否选中当前项功能,checkedOnEntered 默认为 true diff --git a/.changeset/yellow-plums-boil.md b/.changeset/yellow-plums-boil.md new file mode 100644 index 000000000..efa16b23a --- /dev/null +++ b/.changeset/yellow-plums-boil.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/check-select": minor +--- + +feat: 支持按 Enter 键是否选中当前项功能,checkedOnEntered 默认为 true diff --git a/packages/ui/check-select/src/CheckSelect.tsx b/packages/ui/check-select/src/CheckSelect.tsx index 2d6f7c2a9..aea4cd6f9 100644 --- a/packages/ui/check-select/src/CheckSelect.tsx +++ b/packages/ui/check-select/src/CheckSelect.tsx @@ -73,6 +73,7 @@ export const CheckSelect = forwardRef( renderExtraFooter, onSearch: onSearchProp, fieldNames = DEFAULT_FIELD_NAMES, + checkedOnEntered = true, customRender, tagInputProps, size = 'md', @@ -223,7 +224,7 @@ export const CheckSelect = forwardRef( const handleKeyDown = useLatestCallback((evt: React.KeyboardEvent) => { const { key } = evt - if (key === 'Enter') { + if (key === 'Enter' && checkedOnEntered) { const focusedItem = showData[focusedIndex] if (focusedItem) { @@ -492,6 +493,10 @@ export interface CheckSelectProps * 是否开启查看仅已选功能 */ showOnlyShowChecked?: boolean + /** + * 按Enter键是否选中当前项 + */ + checkedOnEntered?: boolean /** * 自定义渲染选中的内容 */