fix(Select): improved label filtering - #3891
Merged
Merged
Conversation
RylanBot
requested review from
HaixingOoO,
NWYLZW,
ZWkang,
carolin913,
honkinglin and
uyarn
as code owners
October 13, 2025 13:46
commit: |
Contributor
TDesign Component Site Preview Open
|
RylanBot
force-pushed
the
rylan/feat/select/filterable
branch
from
October 15, 2025 07:08
fc47b2a to
8ec8e7d
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves label filtering functionality in the Select component and related components (SelectInput, Cascader, TreeSelect), fixing several issues with custom node rendering and input behavior.
Key Changes:
- Fixed errors when filtering Select options with custom label nodes (ReactElements)
- Fixed rendering issues for custom content in Select dropdown options
- Improved single-selection input value display for SelectInput when labels are custom nodes
- Fixed
inputProps.inputClassnot being applied correctly
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
packages/components/select/base/Select.tsx |
Added extractTextFromTNode utility to enable filtering custom label nodes; fixed type annotations |
packages/components/select/base/Option.tsx |
Added auto-height styling for custom element content; removed unreachable return statement |
packages/components/select/_example/custom-options.tsx |
Refactored demo to show both slot-based and content attribute approaches for custom options |
packages/components/select-input/useSingle.tsx |
Refactored single-select value display logic to properly render custom label nodes with absolute positioning |
packages/components/_util/parseTNode.ts |
Added extractTextFromTNode utility function to recursively extract text from TNode structures |
packages/components/tree-select/TreeSelect.tsx |
Simplified input value logic by removing redundant display handling code |
test/snap/__snapshots__/ssr.test.jsx.snap |
Updated snapshots to reflect DOM structure changes |
test/snap/__snapshots__/csr.test.jsx.snap |
Updated snapshots to reflect DOM structure changes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
RylanBot
force-pushed
the
rylan/feat/select/filterable
branch
from
October 16, 2025 07:36
9d1f8c9 to
ba42885
Compare
RylanBot
commented
Jan 16, 2026
| return normalizedValue.length ? displayNode : ''; | ||
| }, [valueDisplay, multiple, normalizedValue]); | ||
|
|
||
| const internalInputValueDisplay: SelectInputProps['valueDisplay'] = useMemo(() => { |
Collaborator
Author
There was a problem hiding this comment.
这些逻辑全部交给 SelectInput 的 useSingle 内部处理
| const labelNode = showLabelNode ? ( | ||
| <div | ||
| style={{ | ||
| position: 'absolute', |
Collaborator
Author
RylanBot
force-pushed
the
rylan/feat/select/filterable
branch
from
June 25, 2026 08:47
bfe5aa5 to
377b6cc
Compare
RylanBot
force-pushed
the
rylan/feat/select/filterable
branch
from
June 25, 2026 14:36
377b6cc to
c7a6af5
Compare
RylanBot
commented
Jun 26, 2026
RylanBot
force-pushed
the
rylan/feat/select/filterable
branch
from
July 2, 2026 08:29
6c1d132 to
279b68e
Compare
RylanBot
force-pushed
the
rylan/feat/select/filterable
branch
from
July 2, 2026 08:33
279b68e to
bd018e4
Compare
RylanBot
force-pushed
the
rylan/feat/select/filterable
branch
from
July 2, 2026 10:02
b7eff27 to
358b05d
Compare
RylanBot
commented
Jul 15, 2026
Collaborator
|
/update-common |
uyarn
approved these changes
Jul 17, 2026
uyarn
approved these changes
Jul 17, 2026
uyarn
approved these changes
Jul 17, 2026
16 tasks
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.



🤔 这个 PR 的性质是?
🔗 相关 Issue
TreeSelectDemo 代码 1
💡 需求背景和解决方案
Cascader:Select:(历史相关 PR:#973 (comment))label只要不是string,哪怕不是TNode,是纯数字或者布尔也会出问题Demo 代码 2
(截图为当前效果...Input 框的撑开高度交给用户自己设置
inputClass更加自由,下拉框的选项高度,通过组件库主动给高度设min-height比较合理)📝 更新日志
tdesign-react
fix(Select): 修复
label为非string类型时,开启filterable搜索后报错的问题。fix(Select): 修复使用
label/content/children自定义元素时,下拉框选项的高度没有撑开的问题。 (common#2537)fix(SelectInput): 修复单选且
valueDisplay为自定义元素时,开启filterable无法显示输入内容的问题。fix(SelectInput): 修复⚠️
inputProps.inputClass无法生效的问题。先前inputProps.className被错误地应用到了t-class同级位置,导致正确的inputProps.inputClass配置无效,之前使用相关属性的业务注意此变更feat(SelectInput): 支持
focus时的内容为valueDisplay的对应值。本条 PR 不需要纳入 Changelog
☑️ 请求合并前的自查清单