From cfc42307133d539999b1a4f906eb530e18963c87 Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sat, 8 Aug 2026 22:26:38 +0200 Subject: [PATCH] fix(ereader): restore cover position when navigating back to the cover previous_page() set the on-cover flag but left current_position at the first content block, so "showing the cover" had two different internal representations depending on how you got there: block 0 on a fresh load, block 1 after going forward and back. current_position is what gets persisted, so closing the book while on the cover reopened it past the cover, silently losing it. Reset current_position to block 0 when returning to the cover, matching where a fresh load sits. Co-Authored-By: Claude Opus 5 --- pyWebLayout/layout/ereader_manager.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyWebLayout/layout/ereader_manager.py b/pyWebLayout/layout/ereader_manager.py index ae368b2..6c4848c 100644 --- a/pyWebLayout/layout/ereader_manager.py +++ b/pyWebLayout/layout/ereader_manager.py @@ -453,6 +453,12 @@ class EreaderLayoutManager: # Special case: if at the beginning of content and there's a cover, go back to it if self._has_cover and self._is_at_beginning() and not self._on_cover_page: self._on_cover_page = True + # Restore the canonical cover position. Being on the cover must have a + # single representation: a fresh load sits at block 0 with the cover + # showing, so returning to the cover has to land there too. Leaving the + # position at the first content block saves a position that reopens past + # the cover, silently losing it. + self.current_position = RenderingPosition() self._notify_position_changed() return self.get_current_page()