Repository navigation
Conversation
lnuxe
requested review from
anlyyao,
betavs,
jarmywang,
jin0209,
novlan1 and
zydemail
as code owners
November 11, 2026 11:54
anlyyao
reviewed
Nov 12, 2026
| const { value, cursor } = event.detail; | ||
| this.updateValue(value); | ||
| this.triggerEvent('change', { value: this.data.value, cursor }); | ||
| const nextValue = this.updateValue(value); |
Author
There was a problem hiding this comment.
已移除。本 PR 现在只包含 packages/components/tree-select/tree-select.ts 与 packages/components/tree-select/__test__/index.test.js 两个文件,textarea 的改动已从分支中剔除(见 2d3c9c1)。
lnuxe
force-pushed
the
fix/tree-select-switch-root-columns
branch
from
November 13, 2026 01:47
ca5fd5c to
46221dc
Compare
Author
|
已按 review 意见调整:
现在改动范围: 本地验证: |
This was referenced Nov 13, 2026
onRootChange only wrote innerValue[0] and dispatched change. The deeper columns still held the previous root's candidates, so switching root left the middle column showing the old branch, and the highlight check item.value === innerValue[level] matched nothing in the new column. Write the new root back to data.value, clear the deeper selections and let buildTreeOptions derive them again from the new branch. fix Tencent#4664
Review feedback: keep one unit test file per component instead of adding a new file per scenario. The two switch-parent cases now live in index.test.js under their own describe block, and switch-parent.test.js is gone. No behaviour change.
lnuxe
force-pushed
the
fix/tree-select-switch-root-columns
branch
from
November 17, 2026 02:04
46221dc to
2d3c9c1
Compare
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
close #4664
💡 需求背景和解决方案
问题
issue #4664:切换父级后,之前的子级选中样式丢失。
实际表现比「样式丢失」更彻底——切换到新父级后,中间列根本不刷新,仍显示上一个父级的分支。
以三层结构为例,
value: ['a', 'a2', 'a2x']起手,切到父级b之后:中间列的选中态判断是
item.value === innerValue[level](tree-select.wxml中间层分支),innerValue[1]还是旧父级路径下的'a2',在新列里找不到对应项,于是整列高亮消失——就是 issue 截图里的现象。根因
onRootChange只改了innerValue[0],然后直接派发 change:treeOptions的唯一重建入口是observers里的value/customValue/options/keys/multiple变化,而这里既没触发buildTreeOptions,也没更新data.value,所以后续列全部停留在旧分支。修改
要点:
data.value再重建:buildTreeOptions靠data.value[level]逐层匹配分支(currentLevelOptions.find(child => child.value === currentValue)),只改局部innerValue它看不到;undefined而不是删掉数组元素,让buildTreeOptions回退到新分支的第一项,保持列长度与层级一致;this.data.innerValue,与渲染所用数据一致。验证
新增
packages/components/tree-select/__test__/switch-parent.test.js(三层树,A/A1/A2 与 B/B1/B2):innerValue[0]/innerValue[1]必须落在新分支内。反向验证:还原
tree-select.ts后跑:应用修复后 tree-select 全量 15 passed(3 个测试文件,含 3 个 demo 用例),
eslint干净。fix #4664
📝 更新日志
tdesign-miniprogram
☑️ 请求合并前的自查清单