fix(ui-motion): stop leaking elementRef onto emotion-wrapped DOM children - #2672
Open
balzss wants to merge 1 commit into
Open
fix(ui-motion): stop leaking elementRef onto emotion-wrapped DOM children#2672balzss wants to merge 1 commit into
balzss wants to merge 1 commit into
Conversation
Contributor
|
BaseTransition treated `typeof child.type === 'object'` as "this is a
withStyle-decorated InstUI component". That's true of every forwardRef
wrapper, including the one emotion's jsx runtime wraps around any element
carrying a `css` prop — and emotion forwards unknown props straight to the
DOM node:
React does not recognize the `elementRef` prop on a DOM element.
Tray, DrawerTray, RatingIcon v2 and Modal (constrain="parent") all render
such a child, so every tray and dialog built on them logged this.
Introduced in aaa4a58 (#2618), first shipped in v11.7.4; reported by
canvas-lms, where it failed 380 canvas-rce tests.
Narrow the check to children that actually declare `elementRef` in
`allowedProps`. Emotion's wrapper doesn't, so `<div css={...}>` falls back
to the plain `ref` path, while a withStyle child keeps the chained
`elementRef` that #2618 added.
Note this is deliberately not a revert. #2618 fixed LX-4014, where a
withStyle child plus a running transition made React read `ref` off the
element and warn. Reverting `renderChildren` brings that back — verified,
not assumed. Both behaviours are now pinned by tests that bracket the fix:
the leak test fails under the old `typeof` check, and the LX-4014 test
fails under a plain revert.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
balzss
force-pushed
the
fix/ui-motion-elementref-emotion
branch
from
July 31, 2026 11:56
7069332 to
56fa2c9
Compare
Contributor
Visual regression report
Diff images (33)alert.png — baseline no longer producedavatar.png — baseline no longer producedbadge.png — baseline no longer producedbillboard.png — baseline no longer producedbreadcrumb.png — baseline no longer producedbutton-and-derivatives.png — baseline no longer producedbyline.png — baseline no longer producedcalendar.png — baseline no longer producedcheckbox.png — baseline no longer producedcheckboxgroup.png — baseline no longer producedcolorpicker.png — baseline no longer producedcontextview.png — baseline no longer producedcustom-and-lucide-icons.png — baseline no longer produceddateinput-dateinput2.png — baseline no longer produceddatetimeinput.png — baseline no longer produceddiff-demo.png — 6324 pixels differdrilldown.png — baseline no longer producedfiledrop.png — baseline no longer producedform-errors.png — baseline no longer producedheading.png — baseline no longer producedimg.png — baseline no longer producedlink.png — baseline no longer producedmenu.png — baseline no longer producedmetric-pill-tag-timeselect-text.png — baseline no longer producedoptions.png — baseline no longer producedpagination.png — baseline no longer producedprogressbar.png — baseline no longer producedselect-simpleselect.png — baseline no longer producedtable.png — baseline no longer producedtabs.png — baseline no longer producedtooltip.png — baseline no longer producedtreebrowser.png — baseline no longer producedview.png — baseline no longer producedBaselines come from the |
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.

Summary
Any
<Transition>child written with acssprop logs:BaseTransitiontreatedtypeof child.type === 'object'as "withStyle-decorated InstUI component". That's true of every forwardRef wrapper, including the one emotion's jsx runtime wraps around any element carrying acssprop — and emotion forwards unknown props straight to the DOM node. Introduced in aaa4a58 (#2618), shipped in v11.7.4.Affects
Tray,DrawerTray,RatingIconv2 andModal(constrain="parent") — each renders acsschild that resolves to a host element.Changes
elementRefinallowedProps. Emotion's wrapper doesn't, so<div css={...}>takes the plainrefpath; a withStyle child keeps the chainedelementRef.This is deliberately not a revert. #2618 fixed LX-4014, where a withStyle child plus a running transition made React read
refoff the element and warn. I tried the straight revert ofrenderChildrenfirst — it brings LX-4014 back, confirmed rather than assumed.Test Plan
Two tests bracket the fix, so neither behaviour can regress into the other:
typeofcheckelementRefleak on acsshost childref is not a propon a withStyle childwithStyle-decorated child and an actually-running transition — both conditions are required to reproduce, per fix(ui-motion,ui-alerts): capture child DOM via elementRef in Transition to avoid React 'ref is not a prop' warning #2618.ui-motion21 passed.ui-tray ui-drawer-layout ui-modal ui-rating ui-overlays ui-toggle-details ui-tabs ui-popover229 passed. Browser project (incl.ui-alerts) 190 passed.build:typesclean.elementrefattributes in the DOM.Fixes INSTUI-5139
Reported by @drakeaharper in #instui — canvas-rce escalates
console.errorto a failure, so this alone failed 380 tests across 23 files. Supersedes #2667, which proposed the sameallowedPropsgate.🤖 Generated with Claude Code