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
Fix/cascader search #2030
Fix/cascader search #2030
Conversation
… button, option panel still in search status
…d hitting all data
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 6771a3f:
|
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2030 +/- ##
==========================================
- Coverage 87.44% 87.40% -0.05%
==========================================
Files 437 437
Lines 25664 25667 +3
Branches 6504 6502 -2
==========================================
- Hits 22441 22433 -8
- Misses 3223 3234 +11 ☔ View full report in Codecov by Sentry. |
Passing run #2226 ↗︎
Details:
Review all test suite changes for PR #2030 ↗︎ |
@@ -908,7 +908,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter, | |||
if (_notExist) { | |||
return false; | |||
} | |||
const filteredPath = this.getItemPropPath(key, treeNodeFilterProp).join(); | |||
const filteredPath = this.getItemPropPath(key, treeNodeFilterProp).join(''); | |||
return filter(sugInput, data, filterTreeNode, false, filteredPath); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
搜索内容为英文逗号时,匹配全量数据的问题时因为此处拼接级连数据时,用了数组的 join(),引入了多余的英文逗号,导致选项都满足筛选条件
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参数返回值改变,这个不行
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改。 原来 tree/treeSelect/Cascader公用 tree/treeUtils.tsx中的 filter,为修复 cascader 中搜索英文逗号匹配全量数据的问题,同时保证 filterTreeNode 中对外透传的 treeNodeString 不变。另外为了便于理解,将 cascader 的 filter 单独拆分出在 foundation 的 cascader/utils.tsx中
@@ -932,6 +932,7 @@ export default class CascaderFoundation extends BaseFoundation<CascaderAdapter, | |||
const isControlled = this._isControlledComponent(); | |||
const newState: Partial<BasicCascaderInnerData> = {}; | |||
if (multiple) { | |||
newState.isSearching = false; | |||
this._adapter.updateInputValue(''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在点击清除按钮后,已选项和搜索数据都被清空, 应该将 isSearching 修改为 false,和单选的清空状态处理保持一致,否则会造成多选,搜素时,点击清空按钮,选项面板无法从搜索状态转为普通状态
const hasValue = selectedKeys.size; | ||
const multipleWithHaveValue = multiple && checkedKeys.size; | ||
return showClear && (hasValue || multipleWithHaveValue) && !disabled && (isOpen || isHovering); | ||
return showClear && (inputValue || hasValue || multipleWithHaveValue) && !disabled && (isOpen || isHovering); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
设置了 showClear,在有已选项 或者 有搜索值时候,满足其他条件的情况下,都应该显示 清除按钮
…d hitting all data
中文模板 / Chinese Template
What kind of change does this PR introduce? (check at least one)
PR description
Fixes
问题原因,使用了 join引入了多余的 , 逗号
Changelog
🇨🇳 Chinese
🇺🇸 English
Checklist
Other
Additional information