fix(ui-motion): only pass elementRef to children that accept it - #2667
Open
drakeaharper wants to merge 1 commit into
Open
fix(ui-motion): only pass elementRef to children that accept it#2667drakeaharper wants to merge 1 commit into
drakeaharper wants to merge 1 commit into
Conversation
|
|
`BaseTransition` treats `typeof child.type === 'object'` as "this is a
withStyle-decorated InstUI component", but that is true of every
forwardRef wrapper. `@emotion/react`'s wrapper matches it and forwards
unknown props straight to the DOM node, so any emotion element wrapped in
a Transition produces:
Warning: React does not recognize the `elementRef` prop on a DOM
element.
DrawerLayout.Tray hits this, so every tray and dialog built on it logs
the warning. Gate the `elementRef` branch on the child declaring
`elementRef` in `allowedProps`; everything else keeps the plain `ref`
path, which is what shipped before this check existed.
Found while upgrading canvas-lms from 11.7.4-SECURITY.3 to 11.7.4, where
it failed 380 tests in canvas-rce, whose test setup treats console.error
as fatal.
drakeaharper
force-pushed
the
fix/ui-motion-element-ref-leak
branch
from
July 30, 2026 05:01
d15112c to
c32c35f
Compare
Contributor
|
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
BaseTransition.renderChildren()treatstypeof child.type === 'object'as "this is awithStyle-decorated InstUI component":But that's true of every
forwardRefwrapper.@emotion/react's wrapper matches it and forwards unknown props straight to the DOM node, so any emotion element wrapped in aTransitionwarns:DrawerLayout.Trayrenders an emotion element inside aTransition, so every tray and dialog built on it logs this.11.7.4-SECURITY.3usedref+findDOMNodeand never passedelementRef, so this appeared in11.7.4. Still present on11.7.5-snapshot-14.Changes
elementRefbranch on the child actually declaringelementRefinallowedProps. InstUI components decorated withwithStyleexpose it; emotion's wrapper doesn't, so it falls back to the plainrefpath — the behaviour that shipped before this check existed.elementRefstill fires rather than being overwritten.<Transition />covering ref forwarding.Verification
ref, and one proves anallowedProps-declaring child still receives a chainedelementRef— that pair would catch over-correcting by dropping theelementRefbranch entirely.pnpm run test:vitest ui-motion— 21 passed.pnpm run bootstrapclean, includingbuild:types.Context
Found upgrading canvas-lms off the Artifactory-only
11.7.4-SECURITY.3onto public11.7.4. canvas-rce's vitest setup escalatesconsole.errorto a failure, so this alone failed 380 tests across 23 files, all Tray/Dialog specs. Reported in #instui. Canvas is carrying apatch-packagepatch for this that we'll drop once a fixed release ships.Alternative worth considering
Gating on
allowedPropsis the narrowest fix that keeps your new chaining behaviour. If you'd rather not rely on that static, the other options are an explicit opt-in prop on the child, or reverting to the pre-11.7.4ref+findDOMNodeapproach and solving the overwrite problem differently. Happy to reshape this if you prefer one of those.