Skip to content

Commit

Permalink
feat(check-select): 支持回车键不默认选中功能(#2969) (#2970)
Browse files Browse the repository at this point in the history
* feat(check-select): 支持回车键不默认选中功能(#2969)

* chore(check-select): 生成变更记录文件

* chore: update name

---------

Co-authored-by: xiamiao <[email protected]>
  • Loading branch information
xiamiao1121 and xiamiao authored Aug 15, 2024
1 parent f7137e3 commit 657d180
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/eighty-kids-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

feat(check-select): 支持按 Enter 键是否选中当前项功能,checkedOnEntered 默认为 true
5 changes: 5 additions & 0 deletions .changeset/yellow-plums-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/check-select": minor
---

feat: 支持按 Enter 键是否选中当前项功能,checkedOnEntered 默认为 true
7 changes: 6 additions & 1 deletion packages/ui/check-select/src/CheckSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const CheckSelect = forwardRef<HTMLDivElement | null, CheckSelectProps>(
renderExtraFooter,
onSearch: onSearchProp,
fieldNames = DEFAULT_FIELD_NAMES,
checkedOnEntered = true,
customRender,
tagInputProps,
size = 'md',
Expand Down Expand Up @@ -223,7 +224,7 @@ export const CheckSelect = forwardRef<HTMLDivElement | null, CheckSelectProps>(
const handleKeyDown = useLatestCallback((evt: React.KeyboardEvent) => {
const { key } = evt

if (key === 'Enter') {
if (key === 'Enter' && checkedOnEntered) {
const focusedItem = showData[focusedIndex]

if (focusedItem) {
Expand Down Expand Up @@ -492,6 +493,10 @@ export interface CheckSelectProps
* 是否开启查看仅已选功能
*/
showOnlyShowChecked?: boolean
/**
* 按Enter键是否选中当前项
*/
checkedOnEntered?: boolean
/**
* 自定义渲染选中的内容
*/
Expand Down

0 comments on commit 657d180

Please sign in to comment.