aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/features/comp
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2023-08-25 07:26:32 +0200
committerGitHub <noreply@github.com>2023-08-25 13:26:32 +0800
commit636b6eaf2aa987c2fe530aafdbb9f50a2f58afa5 (patch)
tree3935f79ec9e51ec1ea98ef642d367b0f78a052cf /web_src/js/features/comp
parent390ec619f3fe04ad6c91c52813bc17d9963d5322 (diff)
downloadgitea-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.js6
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');