Skip to content

fix(web): Esc in Find in PDF clears it without closing the sheet - #41749

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
only21mil:fix/web-pdf-viewer-find-escape-clear
Nov 24, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
only21mil:fix/web-pdf-viewer-find-escape-clear

Conversation

@only21mil

Copy link
Copy Markdown
Contributor

When a PDF opens in the built-in PDF.js viewer (the desktop app, or any browser without a native PDF viewer), pressing Esc in Find in PDF closes the whole Files sheet or attachment preview instead of clearing the search. The input had no Escape handling, so the key reached the sheet's dismiss handler. Because it was type="search", the browser also cleared it on an Escape that only ends an IME composition.

Fix

The same fix as #41616 for the Files search: the input is now type="text" with role="searchbox" (same accessible name), and its Escape handler clears a non-empty query and stops the key there. A second Esc on the empty field still closes the sheet. IME Escapes (isComposing or keyCode 229) are left alone. Held-down Esc repeats are also stopped, as in #41692, so holding Esc clears the query without also closing the sheet.

Evidence

Setup: Linux, vp run dev --no-seed with isolated state, T3's Browser panel (Chromium reports navigator.pdfViewerEnabled === false, so BrowserDocumentFrame mounts the PDF.js PdfViewer). Window 900px wide so the right panel opens as a sheet. A two-page text PDF in a test project.

Steps: Open the right panel → Files → planning.pdf, type budget in Find in PDF, press Esc.

Before After
Query typed (same on both) Find in PDF with a query typed
After one Esc One Esc closed the Files sheet One Esc cleared Find and kept the sheet open

On the fixed build, a second Esc closed the sheet.

Tests

  • New PdfViewer.browser.test.tsx case renders the viewer inside RightPanelSheet: IME Escapes keep the query, the first Esc clears it without closing the sheet, a repeat Esc does not close it, and the next Esc closes it. Fails on main, passes here.
  • vp test run apps/web/src/components/files/PdfViewer.browser.test.tsx (7 passed), vp run check:changed passes.

Generated with Claude Opus 5.5 in T3 Code Nightly

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6a8be8a and 7ad1ca1.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The PDF search field now preserves its query during IME composition. Escape clears a non-empty query without closing the panel. A later Escape closes the panel.

Changes: PDF Search Escape Handling

Layer / File(s) Summary
Search field Escape behavior
apps/web/src/components/files/PdfViewer.tsx, apps/web/src/components/files/PdfViewer.browser.test.tsx
The search field uses a text input with the searchbox role. Escape does not clear the query during IME composition. A normal Escape clears a non-empty query and stops propagation. Browser tests check composition ordering, query clearing, and panel closure on a subsequent Escape.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: anton-m-r, macroscopeapp

Merge Risk: Minimal · previous review 6a8be

This change makes Escape in the Find in PDF field clear the query before closing the sheet, and it leaves IME composition alone. No actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(web): Esc in Find in PDF clears it without closing the sheet" names the main change: Escape in the PDF Find field now clears the query and no longer closes the Files sheet. It matches t…
Description check Passed The description covers the required template sections. Problem is explained with expected behavior and environment (Linux, PDF.js viewer, Chromium with navigator.pdfViewerEnabled false). Change explai…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(web): Esc in Find in PDF clears it without closing the sheet" names the main change: Escape in the PDF Find field now clears the query and no longer closes the Files sheet. It matches the changeset (PdfViewer.tsx Escape handling and the new browser test) and follows the conventional commit format from the template.

Full details: Description check

Explanation

The description covers the required template sections. Problem is explained with expected behavior and environment (Linux, PDF.js viewer, Chromium with navigator.pdfViewerEnabled false). Change explains the type and role update, the Escape handler, IME handling, and repeat handling. Scope explains the bug fix and references related issues #41616 and #41692. Verification lists the new browser test, the vp test run result (7 passed), check:changed, and before/after screenshots. Minor gap: the Scope section does not link a dedicated issue for this bug. It also does not state the agent model in the required form, though it names one.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5ab8dc4 and 6a8be8a.

Files selected for processing: 2

  • apps/web/src/components/files/PdfViewer.browser.test.tsx
  • apps/web/src/components/files/PdfViewer.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 23, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Open a seeded thread at 900×800 in light theme → Toggle right panel → Files → search for and open plan.pdf → enter budget in Find in PDF → wait for 1/1 → press Escape.

Before After
Commit e65b19d15e 7ad1ca1da6
Search ready Before: budget highlights both lines, counter 1/1 After: budget highlights both lines, counter 1/1
First Escape Before: Files sheet closes After: query and highlights clear, Files sheet remains open
Recording Before recording After recording

On head, repeat Escape retains the sheet; a fresh second Escape dismisses it. The scenario failed on base because Find in PDF disappeared after the first Escape, and passed on head.

Scenario and synthetic PDF generator

Not shown:

  • IME-composition Escape was not exercised with a real input method.
  • Desktop shell and attachment-preview container were not exercised; proof covers the web Files sheet.
  • Held-key repeat was exercised through a repeat=true keyboard event, not a physically held key.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 24, 2026
@juliusmarminge
juliusmarminge merged commit 784da01 into pingdotgg:main Nov 24, 2026
56 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants