From 4d6b26507479030686d5da65e1bec8b353b80bfa Mon Sep 17 00:00:00 2001 From: zhouyun Date: Fri, 13 Sep 2024 09:45:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DTreeSelect=E3=80=81Che?= =?UTF-8?q?ckTreeSelect=E3=80=81Cascader=E3=80=81CheckCascader=E8=AE=BE?= =?UTF-8?q?=E7=BD=AEKeyword=E5=90=8E=E6=95=B0=E6=8D=AE=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E7=9A=84=E9=97=AE=E9=A2=98=20(#2994)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(check-tree-select): 修复 keyword 设置后数据没有过滤的问题 (#2988) * fix: 修复Cascader、CheckCascader、TreeSelect设置keyword数据没有过滤的问题 --- .changeset/perfect-swans-draw.md | 8 ++++++++ .changeset/selfish-apricots-applaud.md | 5 +++++ .changeset/yellow-chicken-shout.md | 7 +++++++ packages/ui/cascader/src/Cascader.tsx | 3 +++ packages/ui/check-cascader/src/CheckCascader.tsx | 3 +++ packages/ui/check-tree-select/src/CheckTreeSelect.tsx | 3 +++ .../ui/check-tree-select/stories/searchable.stories.tsx | 4 ++++ packages/ui/tree-select/src/TreeSelect.tsx | 3 +++ 8 files changed, 36 insertions(+) create mode 100644 .changeset/perfect-swans-draw.md create mode 100644 .changeset/selfish-apricots-applaud.md create mode 100644 .changeset/yellow-chicken-shout.md diff --git a/.changeset/perfect-swans-draw.md b/.changeset/perfect-swans-draw.md new file mode 100644 index 000000000..21c94b3f3 --- /dev/null +++ b/.changeset/perfect-swans-draw.md @@ -0,0 +1,8 @@ +--- +"@hi-ui/hiui": patch +--- + +fix(tree-select): 修复 keyword 设置后数据没有过滤的问题 +fix(check-tree-select): 修复 keyword 设置后数据没有过滤的问题 +fix(cascader): 修复 keyword 设置后数据没有过滤的问题 +fix(check-cascader): 修复 keyword 设置后数据没有过滤的问题 diff --git a/.changeset/selfish-apricots-applaud.md b/.changeset/selfish-apricots-applaud.md new file mode 100644 index 000000000..ba7e4f78b --- /dev/null +++ b/.changeset/selfish-apricots-applaud.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/check-tree-select": patch +--- + +fix: 修复 keyword 设置后数据没有过滤的问题 diff --git a/.changeset/yellow-chicken-shout.md b/.changeset/yellow-chicken-shout.md new file mode 100644 index 000000000..5eaee1f7b --- /dev/null +++ b/.changeset/yellow-chicken-shout.md @@ -0,0 +1,7 @@ +--- +"@hi-ui/cascader": patch +"@hi-ui/check-cascader": patch +"@hi-ui/tree-select": patch +--- + +fix: 修复 keyword 设置后数据没有过滤的问题 diff --git a/packages/ui/cascader/src/Cascader.tsx b/packages/ui/cascader/src/Cascader.tsx index 30a7d678e..7f0fefb32 100644 --- a/packages/ui/cascader/src/Cascader.tsx +++ b/packages/ui/cascader/src/Cascader.tsx @@ -46,6 +46,7 @@ export const Cascader = forwardRef((props, invalid, filterOption, searchable: searchableProp, + keyword: keywordProp, onSearch: onSearchProp, render: titleRender, overlayClassName, @@ -134,6 +135,7 @@ export const Cascader = forwardRef((props, keyword: searchValue, } = useSearchMode({ searchable: searchableProp, + keyword: keywordProp, strategies: [customSearchStrategy, upMatchSearchStrategy], }) @@ -236,6 +238,7 @@ export const Cascader = forwardRef((props, searchable={searchable} scrollable={false} footer={isFunction(renderExtraFooter) && renderExtraFooter()} + keyword={keywordProp} onSearch={callAllFuncs(onSearchProp, onSearch)} trigger={ customRender ? ( diff --git a/packages/ui/check-cascader/src/CheckCascader.tsx b/packages/ui/check-cascader/src/CheckCascader.tsx index 6f8acb8a8..231c7cb05 100644 --- a/packages/ui/check-cascader/src/CheckCascader.tsx +++ b/packages/ui/check-cascader/src/CheckCascader.tsx @@ -66,6 +66,7 @@ export const CheckCascader = forwardRef { return matchUp(item) }, []) + const [keyword, setKeyword] = React.useState('小米') + return ( <>

Searchable

@@ -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) diff --git a/packages/ui/tree-select/src/TreeSelect.tsx b/packages/ui/tree-select/src/TreeSelect.tsx index 421fc5394..27e1c70e4 100644 --- a/packages/ui/tree-select/src/TreeSelect.tsx +++ b/packages/ui/tree-select/src/TreeSelect.tsx @@ -60,6 +60,7 @@ export const TreeSelect = forwardRef( onLoadChildren, render: titleRender, filterOption, + keyword: keywordProp, onSearch: onSearchProp, // ********* popper ********* // // optionWidth, @@ -182,6 +183,7 @@ export const TreeSelect = forwardRef( keyword: searchValue, } = useSearchMode({ searchable: searchableProp, + keyword: keywordProp, strategies: [ dataSourceStrategy, customSearchStrategy, @@ -244,6 +246,7 @@ export const TreeSelect = forwardRef( // onChange={tryChangeValue} // data={mergedData} searchable={searchable} + keyword={keywordProp} onSearch={callAllFuncs(onSearchProp, onSearch)} loading={rest.loading !== undefined ? rest.loading : loading} trigger={