Просмотр исходного кода

Only show compile shortcut when editor is visible (#7773)

GitOrigin-RevId: 0b6d25d7012e82a676e3a782730fb6ca481cd1e8
Alf Eaton 4 лет назад
Родитель
Сommit
ff44afb74c

+ 7 - 2
services/web/frontend/js/features/pdf-preview/components/pdf-compile-button-inner.js

@@ -8,12 +8,17 @@ import { useLayoutContext } from '../../../shared/context/layout-context'
 const modifierKey = /Mac/i.test(navigator.platform) ? 'Cmd' : 'Ctrl'
 
 function PdfCompileButtonInner({ startCompile, compiling }) {
-  const { detachRole } = useLayoutContext()
+  const { detachRole, view, pdfLayout } = useLayoutContext()
 
   const { t } = useTranslation()
 
   const compileButtonLabel = compiling ? t('compiling') + '…' : t('recompile')
 
+  // show the compile shortcut when the editor is visible
+  const showCompileShortcut =
+    detachRole !== 'detached' &&
+    (view === 'editor' || pdfLayout === 'sideBySide')
+
   return (
     <OverlayTrigger
       placement="bottom"
@@ -21,7 +26,7 @@ function PdfCompileButtonInner({ startCompile, compiling }) {
       overlay={
         <Tooltip id="tooltip-logs-toggle" className="keyboard-tooltip">
           {t('recompile_pdf')}{' '}
-          {detachRole !== 'detached' && (
+          {showCompileShortcut && (
             <span className="keyboard-shortcut">({modifierKey} + Enter)</span>
           )}
         </Tooltip>