question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Popover add unwanted scroll because of PopoverContent position

See original GitHub issue

🐛 Bug report

Hello,

I am currently working with Popover and I found a bug.

When a Popover has not been opened yet, the PopoverContent is misplaced and can cause unwanted horizontal scroll. Once it has been opened, the PopoverContent is placed correctly and everything is normal.

💥 Steps to reproduce

Use a Popover at the right of the window and a scroll will happen.

💻 Link to reproduction

See https://codesandbox.io/s/vigorous-dijkstra-d1s2k, the red block is the PopoverContent and as you can see, I’ve set the Popover placement in left but even so, the content is in bottom-end. Hover the button and the content will be placed correctly.

🧐 Expected behavior

PopoverContent should have the correct position event when it’s not been opened.

🧭 Possible Solution

I found a workaround by setting isLazy to the Popover or by setting the PopoverContent in a Portal but I feel like it’s a hacky fix 🤔

🌍 System information

Software Version(s)
Chakra UI 1.6.3
Browser Chrome and Firefox (at least)
Operating System Mac OS Big Sur

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

14reactions
dlindenkreuzcommented, May 28, 2021

Another workaround: https://codesandbox.io/s/floral-mountain-cvoku?file=/src/App.js

<PopoverContent rootProps={{style: {right: 0}}}>
// or
<MenuList rootProps={{style: {right: 0}}}>

This overrides the absolute position so it doesn’t overflow <body>.

As soon as the Popover or Menu is opened, the override gets overridden again 😜 and everything works as usual.

3reactions
microbit-matt-hillsdoncommented, Jun 4, 2021

I’ve seen what I think is the same change in behaviour here in 1.6.3 which I think is caused by deferring creating the popper.js instance as noted in the release note. So for me, the initial placement caused overflow of a 100vh body height but the placement in 1.6.2 and after interacting with the menu did not.

An example of different behaviour: https://codesandbox.io/s/upbeat-solomon-6vttf

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap 3 how to fix content when popover scroll
One way to do that is with the position: absolute css property #foot-notification-pop { position: absolute; bottom: 0px; ...
Read more >
How do I get content in a popover to scroll? — XM Community
To find the element from your browser, go the page with the popover then right click on the text and go to Inspect....
Read more >
Popover - Chakra UI
Popover : The wrapper that provides props, state, and context to its children. PopoverTrigger : Used to wrap the reference (or trigger) element....
Read more >
10 Bootstrap Popover Best Practices - CLIMB
Bootstrap Popovers are a great way to add extra information to your web page without taking up too much space.
Read more >
Popover - Headless UI
In our example we're using absolute positioning on the Popover. ... (perhaps because you need to add an extra wrapper element for one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found