fix: keep ref in props on createElement/cloneElement - #28
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe React element helpers now preserve refs as regular props. ChangesReact ref prop preservation
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The ref-as-prop behavior is implemented and covered across the affected element creation, cloning, and DOM-forwarding paths; no actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)
✨ 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 |
|
Thanks for catching this, Valerii. The ref-as-prop fix is now merged in #29, with your co-author credit, legacy-ref coverage, and size/performance checks. Closing this in favor of the merged PR. |
Base UI's
renderprop silently stopped working under redact —<Tooltip.Trigger render={<Button />} />never opens, same for popovers and menus. No error.It clones the element with a merged ref:
React 19 keeps
refin props (only key/__self/__source are reserved), but redactfollows the React 18 rule and hoists it onto
element.ref, so the cloned functioncomponent gets no ref. The trigger element never reaches the tooltip store and the
hover effect bails before attaching its
mouseenterlistener.Fix:
createElement/cloneElementleaverefin props, andcloneElementskipsit only when
config.ref === undefined, like React does.Summary by CodeRabbit
Bug Fixes
refas a regular prop when creating and cloning React elements, aligning with React 19 behavior.Tests