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:
@ -89,6 +89,7 @@ export function ReaderPage({ bookId }: { bookId: number }) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setReaderControls(idleControls);
|
setReaderControls(idleControls);
|
||||||
|
setPage(1);
|
||||||
setZoom(READER_ZOOM_DEFAULT);
|
setZoom(READER_ZOOM_DEFAULT);
|
||||||
setMode("horizontal");
|
setMode("horizontal");
|
||||||
}, [bookId]);
|
}, [bookId]);
|
||||||
|
|||||||
11
apps/web/src/pages/ReaderPageVerticalRestore.test.ts
Normal file
11
apps/web/src/pages/ReaderPageVerticalRestore.test.ts
Normal 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)");
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user