diff --git a/frontend/src/components/pageEditor/PageEditor.tsx b/frontend/src/components/pageEditor/PageEditor.tsx index 49a97a27d..39458292b 100644 --- a/frontend/src/components/pageEditor/PageEditor.tsx +++ b/frontend/src/components/pageEditor/PageEditor.tsx @@ -69,15 +69,6 @@ const PageEditor = ({ } = usePageEditorState(); const [csvInput, setCsvInput] = useState(''); - const [rightRailVisible, setRightRailVisible] = useState(false); - - useEffect(() => { - const frame = requestAnimationFrame(() => setRightRailVisible(true)); - return () => { - cancelAnimationFrame(frame); - setRightRailVisible(false); - }; - }, []); useEffect(() => { setCsvInput(''); @@ -638,7 +629,6 @@ const PageEditor = ({ usePageEditorRightRailButtons({ totalPages, selectedPageCount, - rightRailVisible, csvInput, setCsvInput, selectedPageIds, diff --git a/frontend/src/components/pageEditor/pageEditorRightRailButtons.tsx b/frontend/src/components/pageEditor/pageEditorRightRailButtons.tsx index 74cff00d0..1abcfe8b0 100644 --- a/frontend/src/components/pageEditor/pageEditorRightRailButtons.tsx +++ b/frontend/src/components/pageEditor/pageEditorRightRailButtons.tsx @@ -9,7 +9,6 @@ import BulkSelectionPanel from './BulkSelectionPanel'; interface PageEditorRightRailButtonsParams { totalPages: number; selectedPageCount: number; - rightRailVisible: boolean; csvInput: string; setCsvInput: (value: string) => void; selectedPageIds: string[]; @@ -28,7 +27,6 @@ export function usePageEditorRightRailButtons(params: PageEditorRightRailButtons const { totalPages, selectedPageCount, - rightRailVisible, csvInput, setCsvInput, selectedPageIds, @@ -45,14 +43,15 @@ export function usePageEditorRightRailButtons(params: PageEditorRightRailButtons const { t } = useTranslation(); - const buttons = useMemo(() => { - const selectAllLabel = typeof t === 'function' ? t('rightRail.selectAll', 'Select All') : 'Select All'; - const deselectAllLabel = typeof t === 'function' ? t('rightRail.deselectAll', 'Deselect All') : 'Deselect All'; - const selectByNumberLabel = typeof t === 'function' ? t('rightRail.selectByNumber', 'Select by Page Numbers') : 'Select by Page Numbers'; - const deleteSelectedLabel = typeof t === 'function' ? t('rightRail.deleteSelected', 'Delete Selected Pages') : 'Delete Selected Pages'; - const exportSelectedLabel = typeof t === 'function' ? t('rightRail.exportSelected', 'Export Selected Pages') : 'Export Selected Pages'; - const closePdfLabel = typeof t === 'function' ? t('rightRail.closePdf', 'Close PDF') : 'Close PDF'; + // Lift i18n labels out of memo for clarity + const selectAllLabel = t('rightRail.selectAll', 'Select All'); + const deselectAllLabel = t('rightRail.deselectAll', 'Deselect All'); + const selectByNumberLabel = t('rightRail.selectByNumber', 'Select by Page Numbers'); + const deleteSelectedLabel = t('rightRail.deleteSelected', 'Delete Selected Pages'); + const exportSelectedLabel = t('rightRail.exportSelected', 'Export Selected Pages'); + const closePdfLabel = t('rightRail.closePdf', 'Close PDF'); + const buttons = useMemo(() => { return [ { id: 'page-select-all', @@ -86,7 +85,7 @@ export function usePageEditorRightRailButtons(params: PageEditorRightRailButtons visible: totalPages > 0, render: ({ disabled }) => ( -
+
@@ -94,7 +93,7 @@ export function usePageEditorRightRailButtons(params: PageEditorRightRailButtons variant="subtle" radius="md" className="right-rail-icon" - disabled={disabled || totalPages === 0 || !rightRailVisible} + disabled={disabled || totalPages === 0} aria-label={selectByNumberLabel} > @@ -153,9 +152,14 @@ export function usePageEditorRightRailButtons(params: PageEditorRightRailButtons ]; }, [ t, + selectAllLabel, + deselectAllLabel, + selectByNumberLabel, + deleteSelectedLabel, + exportSelectedLabel, + closePdfLabel, totalPages, selectedPageCount, - rightRailVisible, csvInput, setCsvInput, selectedPageIds, diff --git a/frontend/src/components/viewer/useViewerRightRailButtons.tsx b/frontend/src/components/viewer/useViewerRightRailButtons.tsx index 95e03c4c4..ea0237518 100644 --- a/frontend/src/components/viewer/useViewerRightRailButtons.tsx +++ b/frontend/src/components/viewer/useViewerRightRailButtons.tsx @@ -13,13 +13,14 @@ export function useViewerRightRailButtons() { const viewer = useViewer(); const [isPanning, setIsPanning] = useState(() => viewer.getPanState()?.isPanning ?? false); - const viewerButtons = useMemo(() => { - const searchLabel = typeof t === 'function' ? t('rightRail.search', 'Search PDF') : 'Search PDF'; - const panLabel = typeof t === 'function' ? t('rightRail.panMode', 'Pan Mode') : 'Pan Mode'; - const rotateLeftLabel = typeof t === 'function' ? t('rightRail.rotateLeft', 'Rotate Left') : 'Rotate Left'; - const rotateRightLabel = typeof t === 'function' ? t('rightRail.rotateRight', 'Rotate Right') : 'Rotate Right'; - const sidebarLabel = typeof t === 'function' ? t('rightRail.toggleSidebar', 'Toggle Sidebar') : 'Toggle Sidebar'; + // Lift i18n labels out of memo for clarity + const searchLabel = t('rightRail.search', 'Search PDF'); + const panLabel = t('rightRail.panMode', 'Pan Mode'); + const rotateLeftLabel = t('rightRail.rotateLeft', 'Rotate Left'); + const rotateRightLabel = t('rightRail.rotateRight', 'Rotate Right'); + const sidebarLabel = t('rightRail.toggleSidebar', 'Toggle Sidebar'); + const viewerButtons = useMemo(() => { return [ { id: 'viewer-search', @@ -118,7 +119,7 @@ export function useViewerRightRailButtons() { ) } ]; - }, [t, viewer, isPanning]); + }, [t, viewer, isPanning, searchLabel, panLabel, rotateLeftLabel, rotateRightLabel, sidebarLabel]); useRightRailButtons(viewerButtons); }