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

[Popover] Want to implement hover #44554

Closed
hengshanMWC opened this issue Nov 26, 2024 · 8 comments
Closed

[Popover] Want to implement hover #44554

hengshanMWC opened this issue Nov 26, 2024 · 8 comments
Assignees
Labels
component: Popover The React component.

Comments

@hengshanMWC
Copy link

hengshanMWC commented Nov 26, 2024

Summary

How to implement the hover function of Button + Popover's children? When my mouse is on the Button, the Popover opens, but the Popover occupies the entire screen and the parent element makes the Popover flash continuously.

Examples

image

Motivation

No response

Search keywords: Popover hover

@hengshanMWC hengshanMWC added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Nov 26, 2024
@zannager zannager added the component: Popover The React component. label Nov 26, 2024
@aarongarciah
Copy link
Member

aarongarciah commented Nov 26, 2024

Hey @hengshanMWC! Please provide a reproduction so we can take a look if you think there's an issue with the Popover component. We have an example in the docs on how to open a Popover on hover: https://mui.com/material-ui/react-popover/#mouse-hover-interaction

@aarongarciah aarongarciah added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 26, 2024
@aarongarciah aarongarciah self-assigned this Nov 26, 2024
@aarongarciah aarongarciah changed the title Want to implement Popover hover [Popover] Want to implement hover Nov 26, 2024
@hengshanMWC
Copy link
Author

hengshanMWC commented Nov 26, 2024

Hey @hengshanMWC! Please provide a reproduction so we can take a look if you think there's an issue with the Popover component. We have an example in the docs on how to open a Popover on hover: https://mui.com/material-ui/react-popover/#mouse-hover-interaction

Hi,Here is a reproducible link@ @aarongarciah
https://codesandbox.io/p/sandbox/laughing-currying-g3vl6l?file=%2Fsrc%2FDemo.js%3A19%2C31

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 26, 2024
@aarongarciah
Copy link
Member

@hengshanMWC may I ask you to explain what are you exactly trying to achieve? What's the specific behavior you want to achieve with the timer in your example?

@aarongarciah aarongarciah added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 26, 2024
@hengshanMWC
Copy link
Author

hengshanMWC commented Nov 26, 2024

@aarongarciah

  1. I hope that when I hover over Typography or div, Popover will be displayed.
  2. The timer is used to ensure that MouseLeave will not immediately close Popover. If the timer is not used, you will leave Typography or div and it will be closed immediately, which cannot achieve 1.
image

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Nov 26, 2024
@hengshanMWC
Copy link
Author

Currently, due to Popver's Modal, the mouse keeps flickering when hovering over Typography.
image

@aarongarciah
Copy link
Member

I think you can achieve the desired behavior with some CSS magic, using pointer-events. The idea is to add pointer-events: none to the Popover root element to disable mouse interactions on the elements that cover the whole page. Then, add pointer-events: auto to the Popover paper element so the Popover content is still accessible using the mouse. Here's a working example: https://codesandbox.io/p/sandbox/laughing-currying-g3vl6l

Please, test this thoroughly and make sure this approach meets your project's criteria (especially in terms of accessibility) before considering this a valid approach.

Let me know if this works for you. Cheers.

@aarongarciah aarongarciah added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 26, 2024
@hengshanMWC
Copy link
Author

@aarongarciah Got it, thanks to you, it was actually a simple CSS problem.https://codesandbox.io/p/sandbox/laughing-currying-g3vl6l?file=%2Fsrc%2FDemo.js%3A34%2C20

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Nov 27, 2024
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@hengshanMWC How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Popover The React component.
Projects
None yet
Development

No branches or pull requests

3 participants