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

GitOrigin-RevId: 0b6d25d7012e82a676e3a782730fb6ca481cd1e8
This commit is contained in:
Alf Eaton 2022-04-27 11:29:40 +01:00 committed by Copybot
parent e5051bcd1d
commit ff44afb74c

View file

@ -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>