diff options
author | silverwind <me@silverwind.io> | 2023-08-25 07:26:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-25 13:26:32 +0800 |
commit | 636b6eaf2aa987c2fe530aafdbb9f50a2f58afa5 (patch) | |
tree | 3935f79ec9e51ec1ea98ef642d367b0f78a052cf /web_src/js/features/comp | |
parent | 390ec619f3fe04ad6c91c52813bc17d9963d5322 (diff) | |
download | gitea-636b6eaf2aa987c2fe530aafdbb9f50a2f58afa5.tar.gz gitea-636b6eaf2aa987c2fe530aafdbb9f50a2f58afa5.zip |
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`.
Diffstat (limited to 'web_src/js/features/comp')
-rw-r--r-- | web_src/js/features/comp/ComboMarkdownEditor.js | 6 |
1 files changed, 6 insertions, 0 deletions
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'); |