From 7d47938cb3fb82cbc0c2e31158eb0bc52d1c164c Mon Sep 17 00:00:00 2001 From: Henry Heino Date: Thu, 8 Feb 2024 09:20:27 -0800 Subject: [PATCH] Desktop: Fixes #9891: Don't rerender markdown notes when the note preview pane is hidden --- .../gui/NoteEditor/NoteBody/CodeMirror/v5/CodeMirror.tsx | 4 ++++ .../gui/NoteEditor/NoteBody/CodeMirror/v6/CodeMirror.tsx | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v5/CodeMirror.tsx b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v5/CodeMirror.tsx index 5136f414125..9174523c06a 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v5/CodeMirror.tsx +++ b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v5/CodeMirror.tsx @@ -611,6 +611,10 @@ function CodeMirror(props: NoteBodyEditorProps, ref: ForwardedRef { let bodyToRender = props.content; + if (!props.visiblePanes.includes('viewer')) { + return; + } + if (!bodyToRender.trim() && props.visiblePanes.indexOf('viewer') >= 0 && props.visiblePanes.indexOf('editor') < 0) { // Fixes https://github.com/laurent22/joplin/issues/217 bodyToRender = `${_('This note has no content. Click on "%s" to toggle the editor and edit the note.', _('Layout'))}`; diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v6/CodeMirror.tsx b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v6/CodeMirror.tsx index e678c0657a8..05625153e79 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v6/CodeMirror.tsx +++ b/packages/app-desktop/gui/NoteEditor/NoteBody/CodeMirror/v6/CodeMirror.tsx @@ -219,6 +219,10 @@ const CodeMirror = (props: NoteBodyEditorProps, ref: ForwardedRef { let bodyToRender = props.content; + if (!props.visiblePanes.includes('viewer')) { + return; + } + if (!bodyToRender.trim() && props.visiblePanes.indexOf('viewer') >= 0 && props.visiblePanes.indexOf('editor') < 0) { // Fixes https://github.com/laurent22/joplin/issues/217 bodyToRender = `${_('This note has no content. Click on "%s" to toggle the editor and edit the note.', _('Layout'))}`;