Skip to content

Commit

Permalink
Remove unnecessary check in the Sidebar component (vercel#606)
Browse files Browse the repository at this point in the history
* refactor: remove unneccessary code

* refactor: remove excessive function call in modal

Co-authored-by: Gonzalo Pozzo <[email protected]>
  • Loading branch information
lsalling and goncy authored Dec 17, 2021
1 parent d1f8ff0 commit 98af5f4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
10 changes: 2 additions & 8 deletions components/ui/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -34,9 +31,6 @@ const Modal: FC<ModalProps> = ({ children, onClose }) => {
window.addEventListener('keydown', handleKey)
}
return () => {
if (modal) {
enableBodyScroll(modal)
}
clearAllBodyScrollLocks()
window.removeEventListener('keydown', handleKey)
}
Expand Down
7 changes: 1 addition & 6 deletions components/ui/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -34,7 +30,6 @@ const Sidebar: FC<SidebarProps> = ({ children, onClose }) => {
}

return () => {
if (contentElement) enableBodyScroll(contentElement)
clearAllBodyScrollLocks()
}
}, [])
Expand Down

0 comments on commit 98af5f4

Please sign in to comment.