fix: preserve non-element children when forwarding refs - #43
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. WalkthroughPortal 改用 ChangesPortal ref 支持
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized fix preserves text and numeric Portal children when refs are supplied, with the reported client, SSR, TypeScript, lint, compile, and combined-suite checks passing; no actionable merge-blocking risk remains beyond normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. ✨ 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 |
Summary
ReactNodechildren when a Portal ref is presentsupportNodeRefto forward refs only to nodes that can actually accept themProblem
PortalProps.childrenacceptsReact.ReactNode, but the ref path unconditionally calledReact.cloneElement. Passing a string or number together with a Portal ref therefore threw an invalid-element error instead of rendering the child.Verification
4f29120a6403b4ac08ad21914107888aad90df9dOpen PR #35 touches the same files for CSP nonce support but a different region. Open PR #9 touches another part of
Portal.tsx; neither implements this behavior.AI assistance disclosure: Codex was used to trace the ref path, check open-PR overlap, draft tests, and run verification. The reported base failures and all passing results were reproduced locally.
Summary by CodeRabbit
Bug 修复
测试