1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

fixed scroll locks on SidebarWrapper

This commit is contained in:
Fedor Katurov 2020-11-21 09:51:55 +07:00
parent f354b4aacc
commit 892e40c87e
2 changed files with 5 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import styles from "./styles.module.scss";
import { clearAllBodyScrollLocks, disableBodyScroll } from "body-scroll-lock";
import { Icon } from "~/components/input/Icon";
import { LoaderCircle } from "~/components/input/LoaderCircle";
import { useCloseOnEscape } from "~/utils/hooks";
interface IProps {
children: React.ReactChild;
@ -39,6 +40,8 @@ const BetterScrollDialog: FC<IProps> = ({
return () => clearAllBodyScrollLocks();
}, [ref]);
useCloseOnEscape(onClose);
return (
<div className={styles.wrap} ref={ref}>
{backdrop && <div className={styles.backdrop}>{backdrop}</div>}

View file

@ -1,7 +1,7 @@
import React, { FC, useEffect, useRef } from 'react';
import styles from './styles.module.scss';
import { createPortal } from 'react-dom';
import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock';
import { useCloseOnEscape } from '~/utils/hooks';
interface IProps {
@ -17,7 +17,7 @@ const SidebarWrapper: FC<IProps> = ({ children, onClose }) => {
if (!ref.current) return;
disableBodyScroll(ref.current, { reserveScrollBarGap: true });
return () => enableBodyScroll(ref.current);
return () => clearAllBodyScrollLocks();
}, [ref.current]);
return createPortal(