) => {
if (renderedRef && event.target === renderedRef.current) {
return;
}
- dispatch(updateLightBoxOptions(null));
+ handleClose();
};
return (
@@ -306,12 +314,7 @@ export const Lightbox = (props: Props) => {
- {
- dispatch(updateLightBoxOptions(null));
- }}
- />
+
{onSave ? : null}
diff --git a/ts/components/lightbox/LightboxGallery.tsx b/ts/components/lightbox/LightboxGallery.tsx
index e1ab69137..d3c4055bf 100644
--- a/ts/components/lightbox/LightboxGallery.tsx
+++ b/ts/components/lightbox/LightboxGallery.tsx
@@ -96,10 +96,10 @@ export const LightboxGallery = (props: Props) => {
useKey(
'Escape',
() => {
- dispatch(updateLightBoxOptions(null));
if (onClose) {
onClose();
}
+ dispatch(updateLightBoxOptions(null));
},
undefined,
[currentIndex, updateLightBoxOptions, dispatch, onClose]
@@ -122,6 +122,7 @@ export const LightboxGallery = (props: Props) => {
onPrevious={hasPrevious ? onPrevious : undefined}
onNext={hasNext ? onNext : undefined}
onSave={handleSave}
+ onClose={onClose}
objectURL={objectURL}
caption={caption}
contentType={selectedMedia.contentType}