-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[material-ui][Transitions] External ownerState
is incorrectly forwarded to inner components
#40653
Comments
@DiegoAndai we would like to pick this up |
@gitstart, sure; let me know if you need help. Thanks. |
What are your thoughts about us setting this prop after the spread operation of childProp? This way, the forwarded ownerState from the Transition component won't be able to override the internal one. By doing so, we can revert the delete operation here, and ownerState can then be forwarded to the custom transition component if needed. |
I think it would be better to avoid destructuring |
@DiegoAndai, for the benefit of future maintainers, we can add comments that explicitly explain the rationale behind relocating the Even though the |
Good point. Let's try moving the |
Steps to reproduce
Link to live example: https://codesandbox.io/p/sandbox/cold-firefly-dpmqj7?file=%2Fsrc%2FDemo.tsx%3A29%2C5
Steps:
ownerState
prop toCollapse
transitionin={true}
initiallyCurrent behavior
The transition is collapsed initially, even though it shouldn't.
Expected behavior
The transition should be expanded initially.
Context
This is a very mild symptom of a bigger underlying problem: If an external
ownerState
is provided to a transition component, then thatownerState
is forwarded to the inner components and treated as the component's ownownerState
. Here's a trace of this usingCollapse
as an example:Collapse
component receives anownerState
propownerState
property goes into...other
other
is provided to TransitionownerState
prop, so it forwards it aschildProps
childProps.ownerState
overrides Collapse's ownownerState
, and the animation breaks.The symptom is only perceivable on the initial render as for subsequent enter calls, the size in handled on the
onEntered
event.The impact of this is that the transition components are unsuitable for usage with the slots pattern: We would like to be able to provide the
ownerState
for custom transitions used in components' slots, but this could have unintended consequences because of the behavior explained above.Another symptom this has is that the
Collapse
transition does not work for theTooltip
component, as it providesownerState
to the transition component.It is not very noticeable at the moment as the Fade, Grow, Slide, and Zoom transitions do not rely on an internal
ownerState
.Discovered while working on #40418. When fixing this issue, we should remove this workaround.
Your environment
npx @mui/envinfo
Search keywords: transitions collapse ownerstate
The text was updated successfully, but these errors were encountered: