fix(Cascader): preserve normalized option keys - #3501
Conversation
Walkthrough
ChangesCascader 属性归一化
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/packages/cascader/__tests__/cascader.spec.tsx (1)
90-108: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win补充真正的无关字段断言。
当前
options只包含text和value。这两个字段都会被归一化字段覆盖,因此断言没有验证...others是否保留无关属性。请加入disabled或其他非text/value字段,并在两个期望结果中断言该字段仍存在。建议修改
- const options = [{ text: '北京', value: '021' }] + const options = [{ text: '北京', value: '021', disabled: true }]同时在两个期望结果中加入:
disabled: true🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/packages/cascader/__tests__/cascader.spec.tsx` around lines 90 - 108, Update the options fixture in the test “normalizes mapped fields after preserving unrelated option fields” to include a non-text/value field such as disabled: true, and add that field to both expected normalized results while preserving the existing mapped-field assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/packages/cascader/__tests__/cascader.spec.tsx`:
- Around line 90-108: Update the options fixture in the test “normalizes mapped
fields after preserving unrelated option fields” to include a non-text/value
field such as disabled: true, and add that field to both expected normalized
results while preserving the existing mapped-field assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e66a43d7-a72b-41f8-8654-d0328faf952c
📒 Files selected for processing (2)
src/packages/cascader/__tests__/cascader.spec.tsxsrc/packages/cascader/utils.ts
🤔 这个变动的性质是?
🔗 相关 Issue
Closes #3429
💡 需求背景和解决方案
当
optionKey将textKey和valueKey映射到同一原始字段时,others会在归一化字段之后展开并覆盖text或value。调整字段展开顺序,先保留其他属性,再写入归一化后的
text、value和children。同时补充两种同字段映射的回归用例。☑️ 请求合并前的自查清单
✅ 验证
pnpm testpnpm buildpnpm build:taroSummary by CodeRabbit
children: undefined状态。