Skip to content

Commit

Permalink
behaviour tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Aug 26, 2022
1 parent c5f4a91 commit 2fee8b4
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions components/src/components/molecules/Backdrop/Backdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const Backdrop = ({
}

toggle(open || false)
if (typeof window !== 'undefined') {
if (typeof window !== 'undefined' && !noBackground) {
if (open) {
if (currBackdrops() === 0) {
setStyles(
Expand All @@ -64,23 +64,19 @@ export const Backdrop = ({
}
modifyBackdrops(1)
return () => {
const top = parseFloat(style.top || '0') * -1
if (currBackdrops() === 1) {
setStyles('', '', '')
window.scroll({
top,
})
}
modifyBackdrops(-1)
window.scroll({ top: parseFloat(style.top || '0') * -1 })
}
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open])

React.useEffect(() => {
return () => {
document.body.style.position = ''
document.body.style.top = ''
}
}, [])
}, [open, noBackground])

return state !== 'unmounted' ? (
<Portal className={className}>
Expand Down

0 comments on commit 2fee8b4

Please sign in to comment.