diff --git a/app/components/Sharing/Collection/SharePopover.tsx b/app/components/Sharing/Collection/SharePopover.tsx index 6e0e37aad..a33655f74 100644 --- a/app/components/Sharing/Collection/SharePopover.tsx +++ b/app/components/Sharing/Collection/SharePopover.tsx @@ -59,6 +59,9 @@ function SharePopover({ collection, visible, onRequestClose }: Props) { useKeyDown( "Escape", (ev) => { + if (!visible) { + return; + } ev.preventDefault(); ev.stopImmediatePropagation(); diff --git a/app/components/Sharing/Document/SharePopover.tsx b/app/components/Sharing/Document/SharePopover.tsx index 81877f787..8bef2e122 100644 --- a/app/components/Sharing/Document/SharePopover.tsx +++ b/app/components/Sharing/Document/SharePopover.tsx @@ -67,6 +67,9 @@ function SharePopover({ useKeyDown( "Escape", (ev) => { + if (!visible) { + return; + } ev.preventDefault(); ev.stopImmediatePropagation();