Skip to content

Commit

Permalink
fix(check-cascader): 修复 PARENT 和 CHILD 模式在搜索场景下 id 丢失问题 (#2750)
Browse files Browse the repository at this point in the history
  • Loading branch information
zyprepare committed Feb 26, 2024
1 parent 9e1765f commit 8cc7d03
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/lucky-dots-speak.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/check-cascader": patch
---

fix: 修复 PARENT 和 CHILD 模式在搜索场景下 id 丢失问题
5 changes: 5 additions & 0 deletions .changeset/thin-vans-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

fix(check-cascader): 修复 PARENT 和 CHILD 模式在搜索场景下 id 丢失问题
4 changes: 3 additions & 1 deletion packages/ui/check-cascader/src/hooks/use-check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ export const useCheck = (

// 入口数据处理
const parsedCheckedIds = parseCheckDataDirty(checkedMode, checkedIds, flattedData, allowCheck)
// 合并 checkedIds,防止部分模式(PARENT和CHILD)在搜索场景下 id 丢失 (https://github.com/XiaoMi/hiui/issues/2750)
const mergedCheckedIds = Array.from(new Set([...parsedCheckedIds, ...checkedIds]))

const cascaded = checkedMode !== 'SEPARATE'

return useCascadeCheck({
cascaded,
disabled,
flattedData,
checkedIds: parsedCheckedIds,
checkedIds: mergedCheckedIds,
onCheck: (checkedIds, checkedNode, shouldChecked, semiCheckedIds) => {
// 出口数据处理
const processedIds = processCheckedIds(checkedMode, checkedIds, flattedData, allowCheck)
Expand Down

0 comments on commit 8cc7d03

Please sign in to comment.