feat(Cascader): add filterable search support#4453
Open
kk-418 wants to merge 2 commits into
Open
Conversation
- 新增 props:filterable / filter / filter-placeholder,开启后顶部展示 t-search 搜索框 - 默认匹配规则参考 ant-design:路径中所有 label 拼接 + 叶子节点 text,做大小写不敏感 includes 匹配 - 命中字用高亮样式(沿用 --td-cascader-active-color,新增 7 个相关 CSS 变量) - 选中扁平结果保留完整路径,自动更新 step/tab 视图后触发 change - 新增 filterable demo、API 文档、6 个单测、8 个语言包补全 filterPlaceholder/empty 文案
将搜索框移入 __content 内部,使弹层总高度回归到 title + 78vh, 不再因新增搜索条而超出安全区。同时在 initOptionsHeight / updateOptionsHeight 中扣除 filterHeight,保证选项滚动区高度计算正确。
commit: |
Collaborator
TDesign Component Site Preview Open
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #4431
Summary
为
Cascader组件新增搜索能力,解决数据层级深时用户逐级查找成本高的痛点。filterable/filter/filter-placeholdert-search,输入关键字后将层级面板切换为扁平的「完整路径」列表ant-design的showSearch:路径中所有 label 拼接(含叶子text)做大小写不敏感includes匹配/分隔;空匹配时展示globalConfig.empty提示selectedIndexes、items、stepIndex,再触发原有change事件,行为与逐级选择一致--td-cascader-filter-*CSS 变量,沿用现有--td-cascader-active-color主题色filterPlaceholder/empty文案Example
自定义匹配(如拼音、远程匹配):
Test plan
pnpm lint通过pnpm test全量通过:133 suites / 703 tests / 384 snapshotsconfig-provider快照已同步(locale 增加filterPlaceholder和empty)_example,进入 Cascader → "支持搜索" demo 手动验证Screenshots