Skip to content
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][Menu] Use Popup instead of Popper #40731

Merged
merged 9 commits into from
Feb 2, 2024

Conversation

michaldudak
Copy link
Member

@michaldudak michaldudak commented Jan 22, 2024

Replaced the Popper with Popup in the Menu implementation.

Similar to #40524, but with Menu.

Breaking change

  • The slotProps.root now accepts the PopupProps instead of the PopperProps

Preview: https://deploy-preview-40731--material-ui.netlify.app/base-ui/react-menu/

@michaldudak michaldudak added component: menu This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base labels Jan 22, 2024
@mui-bot
Copy link

mui-bot commented Jan 22, 2024

Netlify deploy preview

@material-ui/unstyled: parsed: -0.03% 😍, gzip: -0.21% 😍

Bundle size report

Details of bundle changes (Toolpad)
Details of bundle changes

Generated by 🚫 dangerJS against 3f33a8f

@michaldudak michaldudak marked this pull request as ready for review January 22, 2024 12:06
@michaldudak michaldudak changed the title [Menu] Use Popup instead of Popper [base-ui][Menu] Use Popup instead of Popper Jan 22, 2024
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good 😊

I like that we're battle testing the Transitions and Popup API right away and simplifying them ✨

Just had some questions

@@ -71,7 +76,7 @@ const Menu = React.forwardRef((props, ref) => {
return {
...resolvedSlotProps,
className: clsx(
'text-sm box-border font-sans p-1.5 my-3 mx-0 rounded-xl overflow-auto outline-0 bg-white dark:bg-slate-900 border border-solid border-slate-200 dark:border-slate-700 text-slate-900 dark:text-slate-300 min-w-listbox shadow-md dark:shadow-slate-900',
'text-sm box-border font-sans p-1.5 my-3 mx-0 rounded-xl overflow-auto outline-0 bg-white dark:bg-slate-900 border border-solid border-slate-200 dark:border-slate-700 text-slate-900 dark:text-slate-300 min-w-listbox shadow-md dark:shadow-slate-900 [.open_&]:opacity-100 [.open_&]:scale-100 transition-[opacity,transform] [.closed_&]:opacity-0 [.closed_&]:scale-90 [.placement-top_&]:origin-bottom [.placement-bottom_&]:origin-top',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding custom selectors seems like the Tailwind way of doing this instead of using classes. This is probably blocked by the Tailwind plugin after v1, though, right? Just checking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a custom class, so its selector is not included in the Tailwind config we use.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And what would you think about not using CssTransition for the tailwind example and using the hooks directly instead? Wouldn't that be more idiomatic within tailwind users? This usage seems hard to find in the Tailwind docs

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given my near-zero Tailwind experience, I don't know. @danilo-leal, I'd appreciate your input here, as you've used Tailwind more extensively than me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used arbitrary variant selectors with Tailwind very sparsely, but it doesn't feel too strange to me as the [...] brackets API is pretty familiar at this point. But maybe it would be indeed a bit easier to parse if we were using hooks — assuming we'd be able to do something like expanded && 'classes'.

(PS: Slightly off-topic, but I'm curious how this works with the ampersand being at the end 🤔 I'd intuitively assume it should be [&_.open]: instead of [.open_&], matching the example from the doc link Diego shared.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But maybe it would be indeed a bit easier to parse if we were using hooks

Could we merge this PR as is and work on the hook demo separately?

I'm curious how this works with the ampersand being at the end

The open class is applied to the parent element (popup), and we need to style the listbox conditionally depending on this class being present.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we merge this PR as is and work on the hook demo separately?

Sure ✅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we may end up redoing the demos if we decide to change the customization APIs

packages/mui-base/src/Menu/Menu.test.tsx Show resolved Hide resolved
packages/mui-base/src/Menu/Menu.tsx Show resolved Hide resolved
@michaldudak michaldudak merged commit 5f1fd2d into mui:master Feb 2, 2024
22 checks passed
@michaldudak michaldudak deleted the popup-in-menu branch February 2, 2024 07:20
mostafa-rio pushed a commit to mostafa-rio/material-ui that referenced this pull request Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: menu This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants