[Popover][V1] Popover trigger render on scroll
See original GitHub issueBug report
Describe the bug
If I have a popover
on the page every time I scroll the popover rerender.
To reproduce
Scroll the page and you will see the counter increase.
Minimal reproduction
Expected behavior
Do not trigger rerender on scroll.
System information
- Version of @chakra-ui/core: [e.g. 1.0.0-rc.7]
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
React-boostrap Popover not stay with button on scroll container
Expected behavior. A popover should stay with a button element instead of scrolling container. A clear and concise description of what you ...
Read more >Popovers · Bootstrap v5.0
Popovers can be triggered thanks to an element inside a shadow DOM. By default, this component uses the built-in content sanitizer, which strips...
Read more >Popover - Close On Scroll ⋅ Storybook
Name Description Default
placement Where popover should show it's content top
withArrow Whether show popover arrow or not true
initialIsOpen Whether popover visible on init or...
Read more >Changelog - Chakra UI
This improves the render and scroll performance when you use many popper-related items. Affected components: Menu, Popover and Tooltip ...
Read more >Popovers - React-Bootstrap
#Positioned popover components in scrolling container ; container · {this} ; trigger · "click ; placement · "left ; overlay · {popoverLeft} ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
chakra-ui handles the visibility of the Tooltip/Popover/etc with
useDisclosure
and animate the transition on our own with motion. react-popper does not know if its content is visible or not, and rerenders always.To fix this issue react-popper needs the functionality to stop updating its styles if the using side (e.g. chakra-ui) does not need the update to happen.
More context:
Usage of
usePopper
(renamed touseBasePopper
) in chakra-uihttps://github.com/chakra-ui/chakra-ui/blob/54ff9e8105fdce379059b4480203143309ef4aef/packages/popper/src/use-popper.ts#L127-L131
Replace popperJS with a mock
I tried setting the
referenceNode
andpopperNode
conditionally to null, if the content is not visible, but it led to awkward behaviour.Source of the rerender in
usePopper
in react-popperThe
setState
call triggers the rerender:https://github.com/popperjs/react-popper/blob/68a992c07dc145935acbe682fa496f888136e55c/src/usePopper.js#L52-L72
PopoverContent
seems to be the issue here, even without anything in there it rerenders on scroll. This may already be fixed due to the migration tousePopper
, gotta check.Edit: dug a bit, usePopper didn’t help. The rerenders aren’t as bad, only ~ 0.5ms - 1.5ms per Popover, but thats still entirely unneeded so we’ll investigate.