Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(check-select): 支持回车键不默认选中功能(#2969) #2970

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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