mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
fixed scroll locks on SidebarWrapper
This commit is contained in:
parent
f354b4aacc
commit
892e40c87e
2 changed files with 5 additions and 2 deletions
|
@ -3,6 +3,7 @@ import styles from "./styles.module.scss";
|
||||||
import { clearAllBodyScrollLocks, disableBodyScroll } from "body-scroll-lock";
|
import { clearAllBodyScrollLocks, disableBodyScroll } from "body-scroll-lock";
|
||||||
import { Icon } from "~/components/input/Icon";
|
import { Icon } from "~/components/input/Icon";
|
||||||
import { LoaderCircle } from "~/components/input/LoaderCircle";
|
import { LoaderCircle } from "~/components/input/LoaderCircle";
|
||||||
|
import { useCloseOnEscape } from "~/utils/hooks";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
children: React.ReactChild;
|
children: React.ReactChild;
|
||||||
|
@ -39,6 +40,8 @@ const BetterScrollDialog: FC<IProps> = ({
|
||||||
return () => clearAllBodyScrollLocks();
|
return () => clearAllBodyScrollLocks();
|
||||||
}, [ref]);
|
}, [ref]);
|
||||||
|
|
||||||
|
useCloseOnEscape(onClose);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrap} ref={ref}>
|
<div className={styles.wrap} ref={ref}>
|
||||||
{backdrop && <div className={styles.backdrop}>{backdrop}</div>}
|
{backdrop && <div className={styles.backdrop}>{backdrop}</div>}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { FC, useEffect, useRef } from 'react';
|
import React, { FC, useEffect, useRef } from 'react';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock';
|
import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock';
|
||||||
import { useCloseOnEscape } from '~/utils/hooks';
|
import { useCloseOnEscape } from '~/utils/hooks';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
@ -17,7 +17,7 @@ const SidebarWrapper: FC<IProps> = ({ children, onClose }) => {
|
||||||
if (!ref.current) return;
|
if (!ref.current) return;
|
||||||
disableBodyScroll(ref.current, { reserveScrollBarGap: true });
|
disableBodyScroll(ref.current, { reserveScrollBarGap: true });
|
||||||
|
|
||||||
return () => enableBodyScroll(ref.current);
|
return () => clearAllBodyScrollLocks();
|
||||||
}, [ref.current]);
|
}, [ref.current]);
|
||||||
|
|
||||||
return createPortal(
|
return createPortal(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue