MediaModal: make clicking the background close the modal

Fixes https://gitlab.com/soapbox-pub/soapbox/-/issues/1434
This commit is contained in:
Alex Gleason 2023-06-01 12:52:37 -05:00
parent 87b279d8ee
commit 0d8317145d
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -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 (
<div className='media-modal pointer-events-auto fixed inset-0 z-[9999] h-full bg-gray-900/90'>
<div
@ -236,6 +242,7 @@ const MediaModal: React.FC<IMediaModal> = (props) => {
role='presentation'
>
<Stack
onClick={handleClickOutside}
className={
clsx('fixed inset-0 h-full grow transition-all', {
'xl:pr-96': !isFullScreen,