-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[base-ui][Select] Use Popup instead of Popper #40524
Conversation
Netlify deploy preview@material-ui/unstyled: parsed: -0.45% 😍, gzip: -0.29% 😍 Bundle size reportDetails of bundle changes (Toolpad) |
8c86aad
to
02c57c3
Compare
02c57c3
to
8053b35
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing onEntering
and onExiting
makes sense to me, and appreciate the simplification, but I don't quite understand the removal of onEntered
, isn't that still useful?
const { render } = createRenderer(); | ||
const { render: internalRender } = createRenderer(); | ||
|
||
async function render( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: render
might be a confusing name as most tests use render
returned by createRenderer
directly. I would name this renderAndFlush
@@ -220,11 +220,11 @@ const Select = React.forwardRef(function Select< | |||
)} | |||
</Button> | |||
{buttonDefined && ( | |||
<PopperComponent {...popperProps}> | |||
<Popup slots={{ root: PopupComponent }} {...popupProps}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's incredible how surgical this replacement was. Congrats!
* If not specified, the transition will be considered finished end when the first property is transitioned. | ||
* If all properties have the same `transition-duration` (or there is just one transitioned property), this can be omitted. | ||
*/ | ||
lastTransitionedPropertyOnEnter?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How were we able to remove this? What happens in case properties have different transitions for the enter transition?
The sequence of entering goes like that: requested enter -> mount (or remove Exiting: requested exit -> start transition -> finish transition -> fire |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good to me 😊
I did notice that if the popup placement (top/bottom) changes when hidden, then the appearing transition includes the "slide" from the previous position:
Screen.Recording.2024-01-16.at.10.30.52.mov
This is a detail though, only mention it in case we want to fix it, but I don't think it blocks the PR 😊
Nice catch! I'll fix it. |
Replaced the Popper with Popup in the Select implementation.
This also enabled the use of transitions in Select.
Some changes had to be made in the transitions infrastructure, as I encountered a few limitations:
onEntering
callback to be fired, the child could still be hidden by the time we needed it to be focused. This updated behavior is consistent with how Popper works.onEntering
,onEntered
, andonExiting
callbacks were removed from the transition context anduseTransitionTrigger
hook. As a side effect, they are now simpler.Breaking change
popper
slot was renamed topopup
:slotProps.popup
accept the props of the Popup componentslots.popper
used to be a Popper instance by default. Now, theslots.popup
is a plaindiv
and does not require the Popper/Popup instance to be passed in.Part of #38280