From 636b6eaf2aa987c2fe530aafdbb9f50a2f58afa5 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 25 Aug 2023 07:26:32 +0200 Subject: [PATCH] Focus editor on "Write" tab click (#26714) Focus the editor when clicking the "Write" tab. Works for both Textarea and EasyMDE. Does for some reason not work without the `requestAnimationFrame`. --- web_src/js/features/comp/ComboMarkdownEditor.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web_src/js/features/comp/ComboMarkdownEditor.js b/web_src/js/features/comp/ComboMarkdownEditor.js index 9826f2f2bf..d486c5830a 100644 --- a/web_src/js/features/comp/ComboMarkdownEditor.js +++ b/web_src/js/features/comp/ComboMarkdownEditor.js @@ -135,6 +135,12 @@ class ComboMarkdownEditor { $panelPreviewer.attr('data-tab', `markdown-previewer-${elementIdCounter}`); elementIdCounter++; + $tabEditor[0].addEventListener('click', () => { + requestAnimationFrame(() => { + this.focus(); + }); + }); + $tabs.tab(); this.previewUrl = $tabPreviewer.attr('data-preview-url');