From 1587c617ae6fdc13fed52339ec9782a3ef51c334 Mon Sep 17 00:00:00 2001 From: Alexis Barba Date: Sat, 20 Mar 2021 20:58:00 -0700 Subject: [PATCH] Bug fixed: iOS Safari Modal Scrollbar it does not work --- components/ui/Sidebar/Sidebar.tsx | 23 ++++++----------------- package.json | 2 -- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/components/ui/Sidebar/Sidebar.tsx b/components/ui/Sidebar/Sidebar.tsx index a0d5e8339..96f41cd4c 100644 --- a/components/ui/Sidebar/Sidebar.tsx +++ b/components/ui/Sidebar/Sidebar.tsx @@ -1,11 +1,6 @@ import s from './Sidebar.module.css' import Portal from '@reach/portal' -import { FC, useEffect, useRef } from 'react' -import { - disableBodyScroll, - enableBodyScroll, - clearAllBodyScrollLocks, -} from 'body-scroll-lock' +import { FC, useEffect } from 'react' interface Props { children: any @@ -14,25 +9,19 @@ interface Props { } const Sidebar: FC = ({ children, open = false, onClose }) => { - const ref = useRef() as React.MutableRefObject useEffect(() => { - if (ref.current) { - if (open) { - disableBodyScroll(ref.current) - } else { - enableBodyScroll(ref.current) - } - } - return () => { - clearAllBodyScrollLocks() + if (open) { + document.body.style.overflow = 'hidden' + } else { + document.body.style.overflow = 'auto' } }, [open]) return ( {open ? ( -
+