fix(TreeSelect): preserve user selection order#4281
Open
RylanBot wants to merge 5 commits into
Open
Conversation
Collaborator
TDesign Component Site Preview Open
|
commit: |
4d3d900 to
635a7d1
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts multi-select value ordering so that selected items (and rendered Tags) follow the user’s selection sequence rather than the underlying options/tree order, affecting both TreeSelect and Cascader.
Changes:
- Add shared
preserveSelectionOrderhelper to keep prior selected order and append newly selected items. - Update TreeSelect multi-change logic to emit values in preserved user-selection order.
- Update Cascader selection-change logic to preserve order (including
valueType='full'scenarios).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/components/tree-select/TreeSelect.tsx | Uses preserveSelectionOrder when emitting multi-select changes to keep user selection order. |
| packages/components/tree-select/tests/vitest-tree-select.test.jsx | Updates expectations to match new user-selection ordering behavior. |
| packages/components/cascader/core/effect.ts | Integrates ordering preservation into Cascader change effects and refactors tag removal behavior. |
| packages/components/_util/helper.ts | Adds preserveSelectionOrder utility function. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
|
Size Change: 0 B Total Size: 87.8 kB ℹ️ View Unchanged
|
Contributor
|
Size Change: +312 B (+0.03%) Total Size: 920 kB 📦 View Changed
ℹ️ View Unchanged
|
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
💡 需求背景和解决方案
📝 更新日志
tdesign-react
Tag的渲染由 “options顺序” 调整为 “用户选择顺序“,之前依赖相关交互的业务注意此变更Tag的渲染由 “options顺序” 调整为 “用户选择顺序“,之前依赖相关交互的业务注意此变更@tdesign-react/chat
☑️ 请求合并前的自查清单