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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Menu] Fix context menu open position #32661

Merged
merged 1 commit into from May 14, 2022

Conversation

oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented May 6, 2022

Solve one part of https://twitter.com/rsms/status/1522583516265029633 "is the first item perfectly aligned 1px adjacent to the pointer hit pixel?" a point made by rsms. At least, it's how macOS 12, Windows 11, and Figma behave.

Before

https://mui.com/material-ui/react-menu/#context-menu

Screenshot 2022-05-06 at 21 57 25

After

https://deploy-preview-32661--material-ui.netlify.app/material-ui/react-menu/#context-menu

Screenshot 2022-05-06 at 21 59 52


Does click-drag-release work properly? Nop, but it's pretty hard, maybe overkill for us 馃檭. I have also seen https://react-spectrum.adobe.com/react-spectrum/Menu.html support this correctly.


Off-topic. @michaldudak in https://mui.com/base/react-menu/#basic-usage, I think that we will want to reconsider the demo, there are regressions from https://mui.com/material-ui/react-menu/ that would likely not fly in production:

  1. Clicking the menu when open doesn't click it, it blinks
May-06-2022.22-19-04.mp4
  1. We display a language picker, but it's a menu component, this doesn't match (it would match with a select docs page)
  2. The menu items are always mounted, even when closed:

Screenshot 2022-05-06 at 22 21 00

  1. We should prevent users to select text, either by using button or user-select: none

Screenshot 2022-05-06 at 22 27 45


I have asked for review the owners of this component

Screenshot 2022-05-06 at 21 59 11

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation component: menu This is the name of the generic UI component, not the React module! labels May 6, 2022
@mui-bot
Copy link

mui-bot commented May 6, 2022

No bundle size changes

Generated by 馃毇 dangerJS against 9645d47

@brookssolveig
Copy link

Continuous improvement

@michaldudak
Copy link
Member

@oliviertassinari Thanks for reporting these issues.

Clicking the menu when open doesn't click it, it blinks

I'll create an issue for it and fix it when creating the MenuButton component as adding more code to the demo will make it too complex.

We display a language picker, but it's a menu component, this doesn't match (it would match with a select docs page)

Why do you think it's important to have matching demos in different products? The content doesn't really matter, does it? I have no problem with changing it to anything else - just curious about the rationale.

The menu items are always mounted, even when closed
We should prevent users to select text, either by using button or user-select: none

馃憤 I'll create a PR for this

@oliviertassinari
Copy link
Member Author

oliviertassinari commented May 10, 2022

I'll create an issue for it and fix it when creating the MenuButton component as adding more code to the demo will make it too complex.

@michaldudak Depending on the estimated time to introduce this component, I think that it could still make sense to do a fix on the demo. This would help sell the idea that we do need a <MenuButton> component, with all the code that it removes. For example, if we wait 6 months to introduce a MenuButton, then in the meantime the menu component is not usable as-is.

Why do you think it's important to have matching demos in different products? The content doesn't really matter, does it? I have no problem with changing it to anything else - just curious about the rationale.

To be clear, the pain point I wanted to raise is not about https://mui.com/material-ui/react-menu/#basic-menu matching with https://mui.com/base/react-menu/#basic-usage but that the demo in https://mui.com/base/react-menu/#basic-usage is confusing on its own, I feel that we showcase as select like use case inside a page dedicated to the menu. I would expect a menu use case. For example, I think that Headless UI approach the demos correctly.

@oliviertassinari oliviertassinari merged commit c96e55a into mui:master May 14, 2022
@oliviertassinari oliviertassinari deleted the menu-fix-context-menu branch May 14, 2022 23:57
frankkluijtmans pushed a commit to frankkluijtmans/material-ui that referenced this pull request May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: menu This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants