1
0
Fork 0

fix(shared): Stop modal from staying open

This commit is contained in:
Joost De Cock 2023-11-27 17:50:44 +01:00
parent 8535b7bdfd
commit d4739c941d
2 changed files with 14 additions and 11 deletions

View file

@ -62,7 +62,12 @@ export const FormControl = ({
className="btn btn-ghost btn-sm btn-circle hover:btn-secondary"
onClick={() =>
setModal(
<ModalWrapper flex="col" justify="top lg:justify-center" slideFrom="right">
<ModalWrapper
flex="col"
justify="top lg:justify-center"
slideFrom="right"
keepOpenOnClick
>
<div className="mdx max-w-prose">{docs}</div>
</ModalWrapper>
)

View file

@ -67,26 +67,24 @@ export const ModalWrapper = ({
transform-all duration-150 ${animation}
bg-${bg} bg-opacity-${bgOpacity} z-50 hover:cursor-pointer
flex flex-${flex} justify-${justify} items-${items} lg:p-12`}
onClick={keepOpenOnClick ? null : close}
onClick={close}
>
{bare ? (
children
) : (
<div
onClick={stopClick}
onClick={keepOpenOnClick ? stopClick : null}
className={`z-30 bg-base-100 p-4 lg:px-8 lg:rounded-lg lg:shadow-lg max-h-full overflow-auto hover:cursor-default ${
fullWidth ? 'w-full' : ''
}`}
>
{children}
{!keepOpenOnClick && (
<button
className="fixed bottom-2 right-2 btn btn-neutral btn-circle lg:hidden"
onClick={close}
>
<CloseIcon className="w-8 h-8" />
</button>
)}
</div>
)}
</div>