Skip to content

Commit 983246a

Browse files
backnotpropclaude
andauthored
fix: prevent CommentPopover from closing when interacting with ImageAnnotator (#226)
The click-outside handler matched only z-[90]/z-[100] classes, missing the ImageAnnotator portal at z-[200]. Replace fragile z-index class matching with a data-popover-layer attribute on all overlay portals. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2cb2152 commit 983246a

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

packages/ui/components/AttachmentsButton.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,14 @@ export const AttachmentsButton: React.FC<AttachmentsButtonProps> = ({
242242
{/* Backdrop */}
243243
<div
244244
className="fixed inset-0 z-[90]"
245+
data-popover-layer
245246
onClick={() => setIsOpen(false)}
246247
/>
247248

248249
{/* Popover content */}
249250
<div
250251
className="fixed z-[100] w-72 bg-card border border-border rounded-xl shadow-2xl p-3"
252+
data-popover-layer
251253
style={{ top: position.top, left: position.left }}
252254
onClick={e => e.stopPropagation()}
253255
>

packages/ui/components/CommentPopover.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ export const CommentPopover: React.FC<CommentPopoverProps> = ({
8787
const target = e.target as Node | null;
8888
if (!target) return;
8989
if (popoverRef.current?.contains(target)) return;
90-
// Don't close if clicking inside an AttachmentsButton portal (z-index 90+)
90+
// Don't close if clicking inside a child portal (AttachmentsButton, ImageAnnotator, etc.)
9191
const el = target as HTMLElement;
92-
if (el.closest?.('[class*="z-[90]"], [class*="z-[100]"]')) return;
92+
if (el.closest?.('[data-popover-layer]')) return;
9393
onClose();
9494
};
9595

packages/ui/components/ImageAnnotator/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ export const ImageAnnotator: React.FC<ImageAnnotatorProps> = ({
201201
return (
202202
<div
203203
className="fixed inset-0 z-[200] flex items-center justify-center bg-background/90 backdrop-blur-sm"
204+
data-popover-layer
204205
onClick={handleBackdropClick}
205206
>
206207
{/* Canvas with image and toolbar */}

0 commit comments

Comments
 (0)