Skip to content

Commit

Permalink
Fixed main page scrollable issue while popup open.
Browse files Browse the repository at this point in the history
  • Loading branch information
prateekkalra authored Oct 16, 2023
1 parent 1d0aab7 commit 66b1595
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/embeds/js/src/features/popup/components/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export const Popup = (props: PopupProps) => {
popupProps.isOpen ?? false
)

const setOverflow = value => document.body.style.setProperty('overflow', value, 'important');

onMount(() => {
const paymentInProgress = getPaymentInProgressInStorage()
if (popupProps.defaultOpen || paymentInProgress) openBot()
Expand Down Expand Up @@ -90,14 +92,14 @@ export const Popup = (props: PopupProps) => {
const openBot = () => {
setIsBotOpened(true)
popupProps.onOpen?.()
document.body.style.overflow = 'hidden'
setOverflow('hidden');
document.addEventListener('pointerdown', closeBot)
}

const closeBot = () => {
setIsBotOpened(false)
popupProps.onClose?.()
document.body.style.overflow = 'auto'
setOverflow('auto');
document.removeEventListener('pointerdown', closeBot)
}

Expand Down

0 comments on commit 66b1595

Please sign in to comment.