From d535f9f28ebb8bab16a096f77da69f3bc8687a3f Mon Sep 17 00:00:00 2001 From: Froidefond Julien Date: Sun, 15 Mar 2026 21:24:11 +0100 Subject: [PATCH] fix: respect RTL direction for reader arrow buttons and swipe navigation Arrow buttons now swap next/previous in RTL mode. Swipe navigation receives isRTL from parent state instead of creating its own independent copy, so toggling direction takes effect immediately without reload. Co-Authored-By: Claude Opus 4.6 --- src/components/reader/PhotoswipeReader.tsx | 1 + src/components/reader/components/ControlButtons.tsx | 4 ++-- src/components/reader/hooks/useTouchNavigation.ts | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/reader/PhotoswipeReader.tsx b/src/components/reader/PhotoswipeReader.tsx index 88c9099..0839b84 100644 --- a/src/components/reader/PhotoswipeReader.tsx +++ b/src/components/reader/PhotoswipeReader.tsx @@ -76,6 +76,7 @@ export function PhotoswipeReader({ book, pages, onClose, nextBook }: BookReaderP onPreviousPage: handlePreviousPage, onNextPage: handleNextPage, pswpRef, + isRTL, }); // Activer le zoom dans le reader en enlevant la classe no-pinch-zoom diff --git a/src/components/reader/components/ControlButtons.tsx b/src/components/reader/components/ControlButtons.tsx index 9890c63..3abc683 100644 --- a/src/components/reader/components/ControlButtons.tsx +++ b/src/components/reader/components/ControlButtons.tsx @@ -173,7 +173,7 @@ export const ControlButtons = ({ icon={ChevronLeft} onClick={(e) => { e.stopPropagation(); - onPreviousPage(); + direction === "rtl" ? onNextPage() : onPreviousPage(); }} tooltip={t("reader.controls.previousPage")} iconClassName="h-8 w-8" @@ -193,7 +193,7 @@ export const ControlButtons = ({ icon={ChevronRight} onClick={(e) => { e.stopPropagation(); - onNextPage(); + direction === "rtl" ? onPreviousPage() : onNextPage(); }} tooltip={t("reader.controls.nextPage")} iconClassName="h-8 w-8" diff --git a/src/components/reader/hooks/useTouchNavigation.ts b/src/components/reader/hooks/useTouchNavigation.ts index 7e52e68..ee5cbcc 100644 --- a/src/components/reader/hooks/useTouchNavigation.ts +++ b/src/components/reader/hooks/useTouchNavigation.ts @@ -1,18 +1,18 @@ import { useCallback, useRef, useEffect } from "react"; -import { useReadingDirection } from "./useReadingDirection"; interface UseTouchNavigationProps { onPreviousPage: () => void; onNextPage: () => void; pswpRef: React.MutableRefObject; + isRTL: boolean; } export function useTouchNavigation({ onPreviousPage, onNextPage, pswpRef, + isRTL, }: UseTouchNavigationProps) { - const { isRTL } = useReadingDirection(); const touchStartXRef = useRef(null); const touchStartYRef = useRef(null); const isPinchingRef = useRef(false);