fix(web): lecteur mode vertical — réinitialiser la page à l'ouverture d'un autre livre pour démarrer en haut du document (bug #38)

This commit is contained in:
Git Agent
2026-08-24 16:58:25 +02:00
parent e65cc166c8
commit b15920c441
2 changed files with 12 additions and 0 deletions

View File

@ -89,6 +89,7 @@ export function ReaderPage({ bookId }: { bookId: number }) {
useEffect(() => {
setReaderControls(idleControls);
setPage(1);
setZoom(READER_ZOOM_DEFAULT);
setMode("horizontal");
}, [bookId]);

View File

@ -0,0 +1,11 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
describe("ReaderPage vertical restore", () => {
it("resets the reader page when opening another book so an invalid progression starts at the top", () => {
const source = readFileSync(new URL("./ReaderPage.tsx", import.meta.url), "utf8");
const bookResetEffect = source.slice(source.indexOf("useEffect(() => {\n setReaderControls"), source.indexOf(" useEffect(() => {\n if (book?.format", source.indexOf("useEffect(() => {\n setReaderControls")));
expect(bookResetEffect).toContain("setPage(1)");
});
});