mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 03:23:45 -05:00
Refocus the PDF viewer after zooming with a keyboard shortcut (#19959)
GitOrigin-RevId: 61961ca4d5e6362923c7157296308c213649d4f3
This commit is contained in:
parent
692b3c0a2b
commit
806250a30e
1 changed files with 7 additions and 8 deletions
|
@ -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}
|
||||
>
|
||||
<div
|
||||
className="pdfjs-viewer-inner"
|
||||
tabIndex={0}
|
||||
onKeyDown={handleKeyDown}
|
||||
role="tabpanel"
|
||||
>
|
||||
<div className="pdfjs-viewer-inner" tabIndex={0} role="tabpanel">
|
||||
<div className="pdfViewer" />
|
||||
</div>
|
||||
{toolbarInfoLoaded && (
|
||||
|
|
Loading…
Reference in a new issue