mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3363] [Issue]: In-chat Gallery closes when interacting with an opened image (Copy prompt / selecting text) #1820
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1820
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jul 8, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3363
Originally assigned to: @kolacheee on GitHub.
Summary
In the in-chat Gallery, opening an image (its fullscreen preview) and then interacting with it — clicking Copy prompt, selecting the prompt text, or even clicking the image — closes the entire Gallery drawer. On Copy prompt there is also no "Prompt copied." toast (and the prompt may not actually be copied), because the Gallery closes before the copy runs.
Expected behavior
Actual behavior
Any pointer-down inside the opened image preview closes the whole Gallery drawer:
Steps to reproduce
Environment
Logs, screenshots, or video
User-reported with a screen recording: open Gallery → open image → Copy prompt exits the Gallery with no toast; retry → selecting the prompt text exits the Gallery again.
Additional context
Root cause — a single bug behind both symptoms.
ChatGalleryDrawerregisters a document-level, capture-phasepointerdownlistener that closes the drawer whenever the pointer-down target is outside the drawer (packages/client/src/components/chat/ChatGalleryDrawer.tsx:60-70):The image preview
ChatImageLightboxis rendered withcreatePortal(..., document.body)(packages/client/src/components/chat/ChatImageLightbox.tsx:71), so its DOM lives directly ondocument.body— outside bothpanelRefand any[data-chat-floating-panel]. So any pointer-down inside the lightbox (the Copy prompt button, the prompt text, the image) matches neither exclusion and triggersonClose(), closing the whole Gallery drawer.Because the listener is registered in the capture phase (
addEventListener(..., true)), thestopPropagation()calls on the lightbox/panel's bubble-phaseonPointerDown(ChatImageLightbox.tsx:107,ImagePromptPanel.tsx:34&:43) fire too late to stop it — capture runs first.This one cause explains the missing toast too: the pointer-down closes the drawer (unmounting
ChatGalleryand the lightbox) before the Copy button'sonClickhandler can run — and that handler is where the copy + toast live (handleCopyPrompt→toast.success("Prompt copied."),ImagePromptPanel.tsx:19-29). So the copy/toast never fire. It is not intended that Copy prompt closes the Gallery; the copy handler closes nothing.The video preview
ChatVideoLightboxis also adocument.bodyportal (ChatImageLightbox.tsx:177), so it has the same problem.Suggested fix: exclude the lightbox portal from the drawer's outside-close check. Options, cheapest first:
returnwhentarget.closest('[role="dialog"]')— the lightbox isrole="dialog" aria-modal="true", so this covers both image and video previews (and any future modal on top of the drawer).data-chat-floating-panel(reuse the existing exclusion pattern).aria-modaldialog on top should block the drawer's outside-click entirely).Any of these keeps the Gallery open during image interactions and lets the "Prompt copied." toast fire on Copy prompt.
Template check