Skip to content

Commit

Permalink
fix: 修复TreeSelect、CheckTreeSelect、Cascader、CheckCascader设置Keyword后数据没…
Browse files Browse the repository at this point in the history
…有过滤的问题 (#2994)

* fix(check-tree-select): 修复 keyword 设置后数据没有过滤的问题 (#2988)

* fix: 修复Cascader、CheckCascader、TreeSelect设置keyword数据没有过滤的问题
  • Loading branch information
zyprepare authored Sep 13, 2024
1 parent 102d01a commit 4d6b265
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changeset/perfect-swans-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@hi-ui/hiui": patch
---

fix(tree-select): 修复 keyword 设置后数据没有过滤的问题
fix(check-tree-select): 修复 keyword 设置后数据没有过滤的问题
fix(cascader): 修复 keyword 设置后数据没有过滤的问题
fix(check-cascader): 修复 keyword 设置后数据没有过滤的问题
5 changes: 5 additions & 0 deletions .changeset/selfish-apricots-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/check-tree-select": patch
---

fix: 修复 keyword 设置后数据没有过滤的问题
7 changes: 7 additions & 0 deletions .changeset/yellow-chicken-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@hi-ui/cascader": patch
"@hi-ui/check-cascader": patch
"@hi-ui/tree-select": patch
---

fix: 修复 keyword 设置后数据没有过滤的问题
3 changes: 3 additions & 0 deletions packages/ui/cascader/src/Cascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const Cascader = forwardRef<HTMLDivElement | null, CascaderProps>((props,
invalid,
filterOption,
searchable: searchableProp,
keyword: keywordProp,
onSearch: onSearchProp,
render: titleRender,
overlayClassName,
Expand Down Expand Up @@ -134,6 +135,7 @@ export const Cascader = forwardRef<HTMLDivElement | null, CascaderProps>((props,
keyword: searchValue,
} = useSearchMode({
searchable: searchableProp,
keyword: keywordProp,
strategies: [customSearchStrategy, upMatchSearchStrategy],
})

Expand Down Expand Up @@ -236,6 +238,7 @@ export const Cascader = forwardRef<HTMLDivElement | null, CascaderProps>((props,
searchable={searchable}
scrollable={false}
footer={isFunction(renderExtraFooter) && renderExtraFooter()}
keyword={keywordProp}
onSearch={callAllFuncs(onSearchProp, onSearch)}
trigger={
customRender ? (
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/check-cascader/src/CheckCascader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const CheckCascader = forwardRef<HTMLDivElement | null, CheckCascaderProp
// search
filterOption,
searchable: searchableProp,
keyword: keywordProp,
onSearch: onSearchProp,
overlayClassName,
type = 'tree',
Expand Down Expand Up @@ -150,6 +151,7 @@ export const CheckCascader = forwardRef<HTMLDivElement | null, CheckCascaderProp
keyword: searchValue,
} = useSearchMode({
searchable: searchableProp,
keyword: keywordProp,
strategies: [customSearchStrategy, upMatchSearchStrategy],
})

Expand Down Expand Up @@ -243,6 +245,7 @@ export const CheckCascader = forwardRef<HTMLDivElement | null, CheckCascaderProp
searchable={searchable}
scrollable={false}
footer={isFunction(renderExtraFooter) && renderExtraFooter()}
keyword={keywordProp}
onSearch={callAllFuncs(onSearchProp, onSearch)}
trigger={
customRender ? (
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/check-tree-select/src/CheckTreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const CheckTreeSelect = forwardRef<HTMLDivElement | null, CheckTreeSelect
onLoadChildren,
render: titleRender,
filterOption,
keyword: keywordProp,
onSearch: onSearchProp,
// emptyContent,
// ********* popper ********* //
Expand Down Expand Up @@ -223,6 +224,7 @@ export const CheckTreeSelect = forwardRef<HTMLDivElement | null, CheckTreeSelect
keyword: searchValue,
} = useSearchMode({
searchable: searchableProp,
keyword: keywordProp,
strategies: [
dataSourceStrategy,
customSearchStrategy,
Expand Down Expand Up @@ -349,6 +351,7 @@ export const CheckTreeSelect = forwardRef<HTMLDivElement | null, CheckTreeSelect
// onChange={tryChangeValue}
// data={mergedData}
searchable={searchable}
keyword={keywordProp}
onSearch={callAllFuncs(onSearchProp, onSearch)}
footer={renderDefaultFooter()}
loading={rest.loading !== undefined ? rest.loading : loading}
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/check-tree-select/stories/searchable.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export const Searchable = () => {
return matchUp(item)
}, [])

const [keyword, setKeyword] = React.useState('小米')

return (
<>
<h1>Searchable</h1>
Expand All @@ -132,6 +134,8 @@ export const Searchable = () => {
style={{ width: 240 }}
data={data}
searchable
keyword={keyword}
onSearch={setKeyword}
searchMode="filter"
onChange={(checkedIds, options) => {
console.log('CheckTreeSelect onChange: ', checkedIds, options)
Expand Down
3 changes: 3 additions & 0 deletions packages/ui/tree-select/src/TreeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const TreeSelect = forwardRef<HTMLDivElement | null, TreeSelectProps>(
onLoadChildren,
render: titleRender,
filterOption,
keyword: keywordProp,
onSearch: onSearchProp,
// ********* popper ********* //
// optionWidth,
Expand Down Expand Up @@ -182,6 +183,7 @@ export const TreeSelect = forwardRef<HTMLDivElement | null, TreeSelectProps>(
keyword: searchValue,
} = useSearchMode({
searchable: searchableProp,
keyword: keywordProp,
strategies: [
dataSourceStrategy,
customSearchStrategy,
Expand Down Expand Up @@ -244,6 +246,7 @@ export const TreeSelect = forwardRef<HTMLDivElement | null, TreeSelectProps>(
// onChange={tryChangeValue}
// data={mergedData}
searchable={searchable}
keyword={keywordProp}
onSearch={callAllFuncs(onSearchProp, onSearch)}
loading={rest.loading !== undefined ? rest.loading : loading}
trigger={
Expand Down

0 comments on commit 4d6b265

Please sign in to comment.