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] Get broken when using an image as children #26385

Closed
edgar-arroyo-by opened this issue May 19, 2021 · 6 comments
Closed

[Popover] Get broken when using an image as children #26385

edgar-arroyo-by opened this issue May 19, 2021 · 6 comments
Labels

Comments

@edgar-arroyo-by
Copy link

edgar-arroyo-by commented May 19, 2021

  • [X ] The issue is present in the latest release.
  • [ X] I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

After opening the popover twice, if its children is an image, it get broken.

Expected Behavior 🤔

After opening the popover twice, it continue working properly when having an image as a children

Steps to Reproduce 🕹

https://codesandbox.io/s/material-demo-forked-osozn?file=/demo.tsx

Steps:

  1. Open the popover
  2. Close it
  3. Open it again

Context 🔦

Just want to show an image inside a popover
demovideo

@edgar-arroyo-by edgar-arroyo-by added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 19, 2021
@mnajdova
Copy link
Member

After opening the popover twice, if its children is an image, it get broken.

Can you clarify what means broken? I can open the Popover on the link multiple times without issues.

@mnajdova mnajdova added component: Popover The React component. 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 May 20, 2021
@edgar-arroyo-by
Copy link
Author

edgar-arroyo-by commented May 20, 2021

hello there @mnajdova, thanks for your comment

After the first time, you will notice that the position is changed. Like if it lost its anchor element position.

demovideo

@Quintis1212
Copy link

Hi @edgar-arroyo-by ) I will try to fix this

@siriwatknp
Copy link
Member

siriwatknp commented May 23, 2021

@edgar-arroyo-by I believe that this is not a bug in material-ui but an expected behavior because of img is not loaded, so popover cannot calculate the width, after first open image is loaded so the next time you click on the button popover can calculate the width.

I see 2 ways to workaround on this.

  1. pass keepMounted prop to <Popover keepMounted />. This way the img is render and popover is able to calculate the width before user click on the button. However, the popover is now render
  2. pass width height to <img width="1000" height="500" /> to let popover pick up the width even the image is not loaded. https://web.dev/optimize-cls/#modern-best-practice

@edgar-arroyo-by
Copy link
Author

hello there @siriwatknp

you are completely right, thank you a lot for your response!

@oliviertassinari
Copy link
Member

oliviertassinari commented May 31, 2021

@siriwatknp It's also related to #22519. Assuming we rewrite Popover to position with Popper, then we would fix this issue with no extra work once #22303 is done.

@oliviertassinari oliviertassinari added discussion and removed status: waiting for author Issue with insufficient information labels May 31, 2021
@oliviertassinari oliviertassinari changed the title Popover get broken when using an image as children. [Popover] Get broken when using an image as children. May 31, 2021
@oliviertassinari oliviertassinari changed the title [Popover] Get broken when using an image as children. [Popover] Get broken when using an image as children May 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants