Skip to content

fix(app): preview PDF loses page & scroll on preview-tab switch #1367

Description

@jacktrnr

Important

Problem — A PDF scrolled to page N loses its page/scroll when its tab is hidden and shown again: the retained-pool host hides inactive tabs with display:none, which resets scroll, and the PDF's restore logic runs only when its data (base64) changes — not when the tab is re-shown.
Approach — Use the active accessor (#1365) to run the PDF's existing page/scroll restore on the inactive→active transition as well as on data change, and gate view-state reporting while hidden so the collapse doesn't persist a bogus offset.
Scope — in: page + scroll restoration across preview-tab switches for the PDF renderer · out: the text editor (its sibling issue), compile-refresh viewport preservation (already shipped — regression only).
Assumptions — #1365 provides active; the PDF page/scroll restore path and the preview view-state pdf sub-state already exist (shipped, #1250/#1254).

Acceptance Criteria

  • Scrolling a multi-page PDF to page N, hiding the tab, then showing it restores page N and the scroll offset.
  • View-state is not reported (and thus not clobbered) while the tab is hidden.
  • Compile-refresh viewport preservation (page/scroll across a reload) still holds.

Testing Decisions

Extend the PDF canvas tests: restore-on-show of page + scroll, and no report while hidden. Reuse the shipped compile-refresh preservation test as regression.

Key Decisions

Restore is triggered on the active transition by reusing the existing restore path (currently keyed only to a data change), avoiding a second restore implementation. Reporting is gated by active to prevent hide-time clobber, mirroring the editor fix.

Constraints & Invariants

The PDF must not re-decode or reset to page 1 on a mere tab switch. Restore must not fight a user scroll after it completes. No regression to the shipped compile-refresh preservation.

Prior Art

The PDF canvas renderer's restore effect and its page/scroll reporting; the preview view-state pdf sub-state and the preview file view wiring (#1250/#1254).

Source

Part of #1252. Depends on #1365.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions