Skip to content

Commit

Permalink
refactor(modal): inline BodyScrollOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
GregOnNet committed Oct 25, 2023
1 parent e9c57a4 commit f50b16f
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions packages/kit-headless/src/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ import {
useStyles$,
useTask$,
} from '@builder.io/qwik';

import {
activateFocusTrap,
closeModal,
deactivateFocusTrap,
keepModalInPlaceWhileScrollbarReappears as keepModalInPlaceWhenScrollbarReappears,
lockScroll,
overrideNativeDialogEscapeBehaviorWith,
showModal,
trapFocus,
wasModalBackdropClicked,
} from './modal-behavior';

import { disableBodyScroll, type BodyScrollOptions } from 'body-scroll-lock';
import { disableBodyScroll } from 'body-scroll-lock';

import styles from './modal.css?inline';

Expand All @@ -38,10 +37,6 @@ export const Modal = component$((props: ModalProps) => {
useStyles$(styles);
const modalRefSig = useSignal<HTMLDialogElement>();

const scrollOptions: BodyScrollOptions = {
reserveScrollBarGap: true,
};

const { 'bind:show': showSig } = props;

useTask$(async function toggleModal({ track, cleanup }) {
Expand All @@ -60,7 +55,7 @@ export const Modal = component$((props: ModalProps) => {

if (isOpen) {
showModal(modal);
disableBodyScroll(modal, scrollOptions);
disableBodyScroll(modal, { reserveScrollBarGap: true });
props.onShow$?.();
activateFocusTrap(focusTrap);
} else {
Expand All @@ -70,7 +65,6 @@ export const Modal = component$((props: ModalProps) => {

cleanup(() => {
deactivateFocusTrap(focusTrap);
keepModalInPlaceWhenScrollbarReappears(scrollbar, modalRefSig.value);
});
});

Expand Down

0 comments on commit f50b16f

Please sign in to comment.