4
0
forked from crowetic/commerce

Remove unnecessary check in the Sidebar component (#606)

* refactor: remove unneccessary code

* refactor: remove excessive function call in modal

Co-authored-by: Gonzalo Pozzo <gonzalo.pozzo4@gmail.com>
This commit is contained in:
Lars Salling 2021-12-17 15:55:04 +01:00 committed by GitHub
parent d1f8ff007b
commit 98af5f4615
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 14 deletions

View File

@ -2,11 +2,8 @@ import { FC, useRef, useEffect, useCallback } from 'react'
import s from './Modal.module.css'
import FocusTrap from '@lib/focus-trap'
import { Cross } from '@components/icons'
import {
disableBodyScroll,
clearAllBodyScrollLocks,
enableBodyScroll,
} from 'body-scroll-lock'
import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock'
interface ModalProps {
className?: string
children?: any
@ -34,9 +31,6 @@ const Modal: FC<ModalProps> = ({ children, onClose }) => {
window.addEventListener('keydown', handleKey)
}
return () => {
if (modal) {
enableBodyScroll(modal)
}
clearAllBodyScrollLocks()
window.removeEventListener('keydown', handleKey)
}

View File

@ -1,11 +1,7 @@
import { FC, useEffect, useRef } from 'react'
import s from './Sidebar.module.css'
import cn from 'classnames'
import {
disableBodyScroll,
enableBodyScroll,
clearAllBodyScrollLocks,
} from 'body-scroll-lock'
import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock'
interface SidebarProps {
children: any
@ -34,7 +30,6 @@ const Sidebar: FC<SidebarProps> = ({ children, onClose }) => {
}
return () => {
if (contentElement) enableBodyScroll(contentElement)
clearAllBodyScrollLocks()
}
}, [])