fix(preview): PDF resize sticks to the cursor (#295 follow-up) #316

Merged
Cordy merged 5 commits from fix/pdf-preview-resize into main 2026-08-27 01:21:33 +00:00
Owner

Bug

Resizing the preview panel and releasing the mouse doesn't end the drag — the panel keeps tracking the cursor. PDF-only.

Root cause

The divider drag adds mousemove/mouseup listeners on document; the up handler removes them on mouseup. PDF is the only preview rendered in an <iframe> (renderPvBody: if (ext === "pdf") … createElement("iframe")) — images/video/audio/text are same-document elements. When the drag cursor passes over the PDF iframe, mouseup fires inside the iframe's browsing context and never reaches the parent document, so up never runs, move is never removed, and the panel keeps resizing. Images/video/etc. don't capture events, which is why only PDF sticks.

Fix

Set #pvbody { pointer-events: none } for the duration of the drag (on mousedown, cleared in up). With the iframe non-interactive, the drag's mouse events reach the parent document and mouseup fires normally. Two-line change, targets the root cause.

Verified: node --check on the page scripts. (Automated browser testing of iframe event-capture isn't feasible without a real browser — this needs a live click-drag-over-a-PDF to confirm, which is the operator's check.)

Also confirms the finding on #297: office formats (docx/xlsx/pptx) are not previewed today — they fall through to the "No preview" card. That's the still-open #297 feature, not a regression.

## Bug Resizing the preview panel and releasing the mouse doesn't end the drag — the panel keeps tracking the cursor. **PDF-only.** ## Root cause The divider drag adds `mousemove`/`mouseup` listeners on `document`; the `up` handler removes them on `mouseup`. PDF is the only preview rendered in an `<iframe>` (`renderPvBody`: `if (ext === "pdf") … createElement("iframe")`) — images/video/audio/text are same-document elements. When the drag cursor passes over the PDF iframe, `mouseup` fires inside the **iframe's** browsing context and never reaches the parent `document`, so `up` never runs, `move` is never removed, and the panel keeps resizing. Images/video/etc. don't capture events, which is why only PDF sticks. ## Fix Set `#pvbody { pointer-events: none }` for the duration of the drag (on `mousedown`, cleared in `up`). With the iframe non-interactive, the drag's mouse events reach the parent `document` and `mouseup` fires normally. Two-line change, targets the root cause. Verified: `node --check` on the page scripts. (Automated browser testing of iframe event-capture isn't feasible without a real browser — this needs a live click-drag-over-a-PDF to confirm, which is the operator's check.) Also confirms the finding on #297: office formats (docx/xlsx/pptx) are **not** previewed today — they fall through to the "No preview" card. That's the still-open #297 feature, not a regression.
Cordy merged commit b25941eb9b into main 2026-08-27 01:21:33 +00:00
Sign in to join this conversation.
No reviewers
No labels
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: Cordy/Cairn#316
No description provided.