Skip to content

Commit

Permalink
Fix locked body (#213)
Browse files Browse the repository at this point in the history
* Fix locked body

* Fix style

---------

Co-authored-by: Marek Bodinger <marek.bodinger@gmail.com>
  • Loading branch information
MarekBodingerBA and MarekBodinger committed Feb 22, 2023
1 parent 1167bea commit a07273a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions next/modules/common/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ import cx from 'classnames'
import FocusTrap from 'focus-trap-react'
import { AnimatePresence, motion } from 'framer-motion'
import { useTranslation } from 'next-i18next'
import { ReactNode, useRef } from 'react'
import {
AriaOverlayProps,
OverlayContainer,
useModal,
useOverlay,
usePreventScroll,
} from 'react-aria'
import { ReactNode, useEffect, useRef } from 'react'
import { AriaOverlayProps, OverlayContainer, useModal, useOverlay } from 'react-aria'
import { twMerge } from 'tailwind-merge'
import { useIsClient } from 'usehooks-ts'
import { useIsClient, useLockedBody } from 'usehooks-ts'

export type ModalProps = {
children: ReactNode
Expand Down Expand Up @@ -44,7 +38,12 @@ const Modal = (props: ModalProps) => {
{ ...props, isDismissable: isDismissable === undefined ? true : isDismissable },
ref
)
usePreventScroll({ isDisabled: !isOpen })
const [, setLockedBody] = useLockedBody(isOpen)

useEffect(() => {
setLockedBody(isOpen ?? false)
}, [isOpen, setLockedBody])

const { modalProps } = useModal()

const isClient = useIsClient()
Expand Down
2 changes: 1 addition & 1 deletion next/modules/navigation/MobileSubnavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const MobileSubnavigation = ({ isOpen, menuSections, onClose }: SubnavigationPro
</div>
{menuSections.map((section, index) => (
// eslint-disable-next-line react/no-array-index-key
<div key={index} className="py-4 pl-4">
<div key={index} className="p-4">
{/* class pb-[10px] with py-1.5 on MLink makes 16px gap */}
<div className="pb-[10px] text-lg">{section.label}</div>

Expand Down

0 comments on commit a07273a

Please sign in to comment.