From da6609f4d3ad7a98b1fd17be7d241cb4d3f0a57f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juliana=20Pe=C3=B1a?= Date: Wed, 20 Apr 2022 15:34:19 -0700 Subject: [PATCH] notebooks: fix cursor jumping and color in markdown blocks (#34227) --- .../markdown/NotebookMarkdownBlock.module.scss | 1 + .../blocks/markdown/NotebookMarkdownBlock.tsx | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/client/web/src/notebooks/blocks/markdown/NotebookMarkdownBlock.module.scss b/client/web/src/notebooks/blocks/markdown/NotebookMarkdownBlock.module.scss index c92dd5838df6..c15afabff446 100644 --- a/client/web/src/notebooks/blocks/markdown/NotebookMarkdownBlock.module.scss +++ b/client/web/src/notebooks/blocks/markdown/NotebookMarkdownBlock.module.scss @@ -13,6 +13,7 @@ :global(.cm-content) { font-family: var(--code-font-family); + caret-color: var(--body-color); } :global(.cm-scroller) { diff --git a/client/web/src/notebooks/blocks/markdown/NotebookMarkdownBlock.tsx b/client/web/src/notebooks/blocks/markdown/NotebookMarkdownBlock.tsx index f9b6a1cfbe14..b90f45e8def2 100644 --- a/client/web/src/notebooks/blocks/markdown/NotebookMarkdownBlock.tsx +++ b/client/web/src/notebooks/blocks/markdown/NotebookMarkdownBlock.tsx @@ -80,11 +80,13 @@ const staticExtensions: Extension[] = [ ] function focusInput(editor: EditorView): void { - editor.focus() - editor.dispatch({ - selection: { anchor: editor.state.doc.length }, - scrollIntoView: true, - }) + if (!editor.hasFocus) { + editor.focus() + editor.dispatch({ + selection: { anchor: editor.state.doc.length }, + scrollIntoView: true, + }) + } } interface NotebookMarkdownBlockProps extends BlockProps, ThemeProps {