Repository navigation
fix(Anchor): render children when items is undefined - #59211
dogledogle wants to merge 1 commit into
Conversation
|
|
👁 Visual Regression Report for PR #59211 Passed ✅
🎊 Congrats! No visual-regression diff found.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughAnchor 现在仅在 ChangesAnchor 子元素回退
Estimated code review effort: 1 (简单) | ~5 分钟 Suggested reviewers: Merge Risk: ⚪ Minimal · up to Anchor now renders child links when items is undefined while preserving empty-array override behavior. The targeted regression coverage supports merge readiness. 🚥 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. 小兔检查 Anchor 旁 Comment |
More templates
commit: |
Bundle ReportChanges will decrease total bundle size by 2 bytes (-0.0%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: antd.min-array-pushAssets Changed:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #59211 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 834 834
Lines 16022 16022
Branches 4206 4206
=========================================
Hits 16022 16022 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
nrps9909
left a comment
There was a problem hiding this comment.
Reviewed exact head 8090af7960402f5da80751dd95a6a942a0b30224.
The added regression fails with the base 4e86b57c2d2fd6c9ca6532c37e22da9c536d5b62 implementation because the fallback child is absent. Restoring this change passes the complete Anchor Jest suite: 8 suites, 96 tests and 41 snapshots, including two independent review probes.
Those probes use real Anchor.Link children and cover omitted/undefined items, explicit empty-array precedence, data-item precedence, nested children, and repeated transitions from undefined to empty array to data and back to undefined. Existing rendering, click, scroll, accessibility and demo coverage also passes. ESLint, Biome and diff checks pass for the two changed files; all 42 applicable remote checks pass (two workflow checks are skipped).
The condition preserves an explicit items={[]} as an intentional override while restoring the children fallback for an absent value.
8090af7 to
7cd0237
Compare
| <div className={anchorClass}> | ||
| <span className={inkClass} ref={spanLinkNodeRef} style={mergedStyles.indicator} /> | ||
| {'items' in props ? createNestedLink(items) : children} | ||
| {items !== undefined ? createNestedLink(items) : children} |
There was a problem hiding this comment.
不过我倾向于暂不合入这个改动。items 与 JSX children 是新旧两套 API,children 已标记为 deprecated;目前实现自 data-driven API 引入后便以 items 属性是否存在来决定渲染来源。
items={undefined} 同时传入 legacy children 的场景比较边缘,目前也没有对应的实际用户问题或复现。对于需要兜底 UI 的业务,建议在调用侧明确处理,例如:
condition ? <Anchor items={anchorItems} /> : <Fallback />如果兜底内容本身也是一组 Anchor 链接,也可以统一转换为 items 数据后传入,避免混用两套 API。
There was a problem hiding this comment.
OK,学习了。那这个 PR 是关掉还是等等其他人的看法?
There was a problem hiding this comment.
都可以。如果你也觉得没必要的话,可以关了。 觉得有必要的话,可以等其他人建议。
7cd0237 to
ade177f
Compare
|
边缘场景,若后面有实际用户反馈再做处理。 |


🤔 这个变动的性质是?
🔗 相关 Issue
N/A
💡 需求背景和解决方案
Anchor 使用属性是否存在来决定渲染
items还是children,导致显式传入items={undefined}时合法的 fallback children 被静默丢弃。本次调整为仅在
items不为undefined时使用数据配置,并补充回归测试。空数组仍会明确覆盖 children,不涉及公开 API 变更。📝 更新日志
childrenwhenitems={undefined}is explicitly provided.items={undefined}时丢弃children的问题。