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(select): 新增带搜索情况下,点击叉号按钮时下拉框同时清空(#2945) #2948

Merged
merged 6 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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/healthy-needles-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/select": minor
---

feat: 新增带搜索情况下,点击叉号按钮时下拉框同时清空
5 changes: 5 additions & 0 deletions .changeset/ten-countries-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

feat(select): 新增带搜索情况下,点击叉号按钮时下拉框同时清空
6 changes: 5 additions & 1 deletion packages/ui/select/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const Select = forwardRef<HTMLDivElement | null, SelectProps>(
onOpen={menuVisibleAction.on}
onClose={menuVisibleAction.off}
searchable={searchable}
keyword={keywordProp}
keyword={searchValue}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处这样改会影响搜索关键字的受控

onSearch={callAllFuncs(onSearchProp, onSearch)}
loading={rest.loading !== undefined ? rest.loading : loading}
footer={renderExtraFooter ? renderExtraFooter() : null}
Expand Down Expand Up @@ -265,6 +265,10 @@ export const Select = forwardRef<HTMLDivElement | null, SelectProps>(
value={value}
onChange={(value, item) => {
tryChangeValue(value, item.raw)
// 非受控模式下清空下拉框
if (value === '') {
onSearch(value)
}
}}
size={size}
data={mergedData}
Expand Down