MediaModal: make clicking the background close the modal
Fixes https://gitlab.com/soapbox-pub/soapbox/-/issues/1434
This commit is contained in:
parent
87b279d8ee
commit
0d8317145d
1 changed files with 7 additions and 0 deletions
|
@ -229,6 +229,12 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleClickOutside: React.MouseEventHandler<HTMLElement> = (e) => {
|
||||||
|
if ((e.target as HTMLElement).tagName === 'DIV') {
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='media-modal pointer-events-auto fixed inset-0 z-[9999] h-full bg-gray-900/90'>
|
<div className='media-modal pointer-events-auto fixed inset-0 z-[9999] h-full bg-gray-900/90'>
|
||||||
<div
|
<div
|
||||||
|
@ -236,6 +242,7 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
|
||||||
role='presentation'
|
role='presentation'
|
||||||
>
|
>
|
||||||
<Stack
|
<Stack
|
||||||
|
onClick={handleClickOutside}
|
||||||
className={
|
className={
|
||||||
clsx('fixed inset-0 h-full grow transition-all', {
|
clsx('fixed inset-0 h-full grow transition-all', {
|
||||||
'xl:pr-96': !isFullScreen,
|
'xl:pr-96': !isFullScreen,
|
||||||
|
|
Loading…
Reference in a new issue