Fix block pagination hotkeys when embeddableVideoPlayer is active

This commit is contained in:
MerlinScheurer
2025-03-29 11:07:47 +01:00
parent e254a848e0
commit 85be8f1114

View File

@@ -1,4 +1,4 @@
import { Link } from 'react-router-dom'; import { Link, useSearchParams } from 'react-router-dom';
import { Fragment } from 'react/jsx-runtime'; import { Fragment } from 'react/jsx-runtime';
import Routes from '../configuration/routes/RouteList'; import Routes from '../configuration/routes/RouteList';
import { useCallback, useEffect } from 'react'; import { useCallback, useEffect } from 'react';
@@ -23,6 +23,9 @@ interface Props {
const Pagination = ({ pagination, setPage }: Props) => { const Pagination = ({ pagination, setPage }: Props) => {
const { total_hits, params, prev_pages, current_page, next_pages, last_page, max_hits } = const { total_hits, params, prev_pages, current_page, next_pages, last_page, max_hits } =
pagination; pagination;
const [searchParams] = useSearchParams();
const videoId = searchParams.get('videoId');
const totalHits = Number(total_hits); const totalHits = Number(total_hits);
const currentPage = Number(current_page); const currentPage = Number(current_page);
@@ -39,7 +42,7 @@ const Pagination = ({ pagination, setPage }: Props) => {
(event: KeyboardEvent) => { (event: KeyboardEvent) => {
const { code } = event; const { code } = event;
if (code === 'ArrowRight') { if (code === 'ArrowRight' && videoId === null) {
if (currentPage === 0 && totalHits > 1) { if (currentPage === 0 && totalHits > 1) {
setPage(2); setPage(2);
return; return;
@@ -52,7 +55,7 @@ const Pagination = ({ pagination, setPage }: Props) => {
setPage(currentPage + 1); setPage(currentPage + 1);
} }
if (code === 'ArrowLeft') { if (code === 'ArrowLeft' && videoId === null) {
if (currentPage === 0) { if (currentPage === 0) {
return; return;
} }
@@ -65,7 +68,7 @@ const Pagination = ({ pagination, setPage }: Props) => {
setPage(currentPage - 1); setPage(currentPage - 1);
} }
}, },
[currentPage, lastPage, setPage, totalHits], [currentPage, lastPage, setPage, totalHits, videoId],
); );
useEffect(() => { useEffect(() => {