chore: fix popover initial scroll

This commit is contained in:
Aman Harwara
2023-08-14 16:00:54 +05:30
parent f95a942f6e
commit b8cbd446b8

View File

@@ -85,17 +85,11 @@ const PositionedPopoverContent = ({
useDisableBodyScrollOnMobile() useDisableBodyScrollOnMobile()
const correctInitialScrollForOverflowedContent = useCallback(() => { const correctInitialScrollForOverflowedContent = useCallback((element: HTMLElement | null) => {
if (popoverElement) { if (element && element.scrollTop > 0) {
setTimeout(() => { element.scrollTop = 0
popoverElement.scrollTop = 0
}, 10)
} }
}, [popoverElement]) }, [])
useLayoutEffect(() => {
correctInitialScrollForOverflowedContent()
}, [popoverElement, correctInitialScrollForOverflowedContent])
const addCloseMethod = useCallback( const addCloseMethod = useCallback(
(element: HTMLDivElement | null) => { (element: HTMLDivElement | null) => {
@@ -150,7 +144,7 @@ const PositionedPopoverContent = ({
styles ? 'scale-100 opacity-100' : 'scale-95 opacity-0', styles ? 'scale-100 opacity-100' : 'scale-95 opacity-0',
className, className,
)} )}
ref={setAnimationElement} ref={mergeRefs([correctInitialScrollForOverflowedContent, setAnimationElement])}
> >
{children} {children}
</div> </div>