[PR #3366] [CLOSED] fix(gallery): keep image/video preview open on a text-selection drag #5904

Closed
opened 2026-10-23 04:04:59 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3366
Author: @kolacheee
Created: 7/8/2026
Status: ❌ Closed

Base: staging ← Head: fix/3363-gallery-lightbox-close


📝 Commits (1)

  • c80dc3d fix(gallery): keep image/video preview open on a text-selection drag (#3363)

📊 Changes

1 file changed (+18 additions, -2 deletions)

View changed files

📝 packages/client/src/components/chat/ChatImageLightbox.tsx (+18 -2)

📄 Description

Linked issue

Closes #3363.

Important: the primary symptom in #3363 — the whole in-chat Gallery drawer closing on any lightbox interaction (Copy prompt, selecting text, clicking the image), plus the missing "Prompt copied." toast — was already fixed on staging by 8f677f789 ("Fix message and agent image prompt edges", #3361), which tags the lightbox portal with data-chat-floating-panel so the drawer's document-level outside-click listener excludes it. This PR handles the one remaining way an image interaction can still dismiss the preview.

Why this change

With the drawer-close fixed, one residual remains. The image/video preview (ChatImageLightbox) closes on a backdrop click via onClick={(e) => { if (e.target === e.currentTarget) onClose() }}. When a text-selection drag starts inside the preview and releases on the backdrop, the browser resolves the click target to the backdrop (the common ancestor of the drag's start and end), so e.target === e.currentTarget is true and the preview closes. So highlighting the prompt text and dragging slightly past the panel still dismisses the image — and #3363 explicitly asks that selecting text not dismiss anything.

What changed

  • packages/client/src/components/chat/ChatImageLightbox.tsx (both the image and video lightbox) — the backdrop now records, on pointerdown, whether the press landed on the backdrop itself, and only closes on click when both the pointer-down and the click are on the backdrop. A genuine backdrop click still closes the preview; a text-selection drag that merely releases on the backdrop does not.

No server, shared, or drawer changes (the drawer fix is already on staging).

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Client build (tsc) and ESLint pass: pnpm --filter @marinara-engine/client build, pnpm --filter @marinara-engine/client lint.
  • Manually verify in a chat's Gallery:
    1. Open an image → drag to select the prompt text, including dragging past the prompt panel onto the black area → the preview stays open and the selection works.
    2. Click the black backdrop normally → the preview closes (unchanged).
    3. Copy prompt → copies with a "Prompt copied." toast, preview and Gallery stay open (this already works after 8f677f789 — worth re-confirming).
    4. Same checks for a video preview.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

Event-handling-only change; no docs or version impact.

UI evidence (if applicable)

N/A — pointer/click event handling only; no visual change.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/3366 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 7/8/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `fix/3363-gallery-lightbox-close` --- ### 📝 Commits (1) - [`c80dc3d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c80dc3d0c23d6b14a4bd7589476a073c5f17ab1b) fix(gallery): keep image/video preview open on a text-selection drag (#3363) ### 📊 Changes **1 file changed** (+18 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatImageLightbox.tsx` (+18 -2) </details> ### 📄 Description ## Linked issue Closes #3363. **Important:** the **primary** symptom in #3363 — the whole in-chat Gallery *drawer* closing on any lightbox interaction (Copy prompt, selecting text, clicking the image), plus the missing *"Prompt copied."* toast — was **already fixed on `staging`** by `8f677f789` ("Fix message and agent image prompt edges", #3361), which tags the lightbox portal with `data-chat-floating-panel` so the drawer's document-level outside-click listener excludes it. This PR handles the **one remaining** way an image interaction can still dismiss the preview. ## Why this change With the drawer-close fixed, one residual remains. The image/video preview (`ChatImageLightbox`) closes on a backdrop click via `onClick={(e) => { if (e.target === e.currentTarget) onClose() }}`. When a **text-selection drag** starts inside the preview and *releases on the backdrop*, the browser resolves the `click` target to the backdrop (the common ancestor of the drag's start and end), so `e.target === e.currentTarget` is true and the preview closes. So highlighting the prompt text and dragging slightly past the panel still dismisses the image — and #3363 explicitly asks that selecting text not dismiss anything. ## What changed - `packages/client/src/components/chat/ChatImageLightbox.tsx` (both the **image** and **video** lightbox) — the backdrop now records, on `pointerdown`, whether the press landed on the backdrop itself, and only closes on `click` when **both** the pointer-down and the click are on the backdrop. A genuine backdrop click still closes the preview; a text-selection drag that merely releases on the backdrop does not. No server, shared, or drawer changes (the drawer fix is already on `staging`). ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Client build (tsc) and ESLint pass: `pnpm --filter @marinara-engine/client build`, `pnpm --filter @marinara-engine/client lint`. - Manually verify in a chat's Gallery: 1. Open an image → drag to select the prompt text, including dragging past the prompt panel onto the black area → the preview **stays open** and the selection works. 2. Click the black backdrop normally → the preview **closes** (unchanged). 3. **Copy prompt** → copies with a *"Prompt copied."* toast, preview and Gallery stay open (this already works after `8f677f789` — worth re-confirming). 4. Same checks for a **video** preview. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) Event-handling-only change; no docs or version impact. ## UI evidence (if applicable) N/A — pointer/click event handling only; no visual change. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:04:59 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5904
No description provided.