diff --git a/services/web/frontend/js/features/pdf-preview/components/pdf-js-viewer.tsx b/services/web/frontend/js/features/pdf-preview/components/pdf-js-viewer.tsx index 6ac2466f13..d9813b9a56 100644 --- a/services/web/frontend/js/features/pdf-preview/components/pdf-js-viewer.tsx +++ b/services/web/frontend/js/features/pdf-preview/components/pdf-js-viewer.tsx @@ -439,7 +439,7 @@ function PdfJsViewer({ url, pdfFile }: PdfJsViewerProps) { const handleKeyDown = useCallback( event => { - if (!initialised) { + if (!initialised || !pdfJsWrapper) { return } if (event.metaKey || event.ctrlKey) { @@ -448,26 +448,30 @@ function PdfJsViewer({ url, pdfFile }: PdfJsViewerProps) { case '=': event.preventDefault() setZoom('zoom-in') + pdfJsWrapper.container.focus() break case '-': event.preventDefault() setZoom('zoom-out') + pdfJsWrapper.container.focus() break case '0': event.preventDefault() setZoom('page-width') + pdfJsWrapper.container.focus() break case '9': event.preventDefault() setZoom('page-height') + pdfJsWrapper.container.focus() break } } }, - [initialised, setZoom] + [initialised, setZoom, pdfJsWrapper] ) useMouseWheelZoom(pdfJsWrapper, setScale) @@ -494,12 +498,7 @@ function PdfJsViewer({ url, pdfFile }: PdfJsViewerProps) { onKeyDown={handleKeyDown} tabIndex={-1} > -