From c56b2d35ff23f785c14eb1799ad8076d0702dc33 Mon Sep 17 00:00:00 2001 From: Grigor Tonikyan Date: Fri, 4 Sep 2026 03:32:11 +0400 Subject: [PATCH] enhance(web): hide attachment dropzone on preview tab in combo editor (#39204) Co-authored-by: wxiaoguang --- templates/repo/issue/fields/textarea.tmpl | 2 +- templates/repo/upload.tmpl | 2 +- web_src/css/editor/combomarkdowneditor.css | 5 +++++ .../js/features/comp/ComboMarkdownEditor.ts | 22 ++++++++++++++----- 4 files changed, 24 insertions(+), 7 deletions(-) diff --git a/templates/repo/issue/fields/textarea.tmpl b/templates/repo/issue/fields/textarea.tmpl index 128da0b7dd9..0788baaa669 100644 --- a/templates/repo/issue/fields/textarea.tmpl +++ b/templates/repo/issue/fields/textarea.tmpl @@ -16,7 +16,7 @@ )}} {{if .root.IsAttachmentEnabled}} -
+
{{/*TODO: need to refactor the "repo/upload" template and remove this wrapper */}} {{template "repo/upload" .root}}
{{end}} diff --git a/templates/repo/upload.tmpl b/templates/repo/upload.tmpl index eef51994ab7..6b29838868d 100644 --- a/templates/repo/upload.tmpl +++ b/templates/repo/upload.tmpl @@ -1,5 +1,5 @@
('.ui.tab[data-tab-panel="markdown-previewer"]')!; // Fomantic Tab requires the "data-tab" to be globally unique. // So here it uses our defined "data-tab-for" and "data-tab-panel" to generate the "data-tab" attribute for Fomantic. @@ -222,12 +230,16 @@ export class ComboMarkdownEditor { initTabSwitcher(elTabular); this.tabEditor.addEventListener('click', () => { + this.updateEditorContainerTabPage('writer'); requestAnimationFrame(() => { this.focus(); }); }); this.tabPreviewer.addEventListener('click', async () => { + // use capture to get the event before Fomantic Tab switches the tab, so that we can set the minHeight of the previewer panel to avoid flickering. + panelPreviewer.style.minHeight = `${panelEditor?.clientHeight}px`; + this.updateEditorContainerTabPage('previewer'); const formData = new FormData(); formData.append('mode', this.previewMode); formData.append('context', this.previewContext); @@ -249,7 +261,7 @@ export class ComboMarkdownEditor { triggerEditorContentChanged(this.container); }); } - }); + }, {capture: true}); } generateMarkdownTable(rows: number, cols: number): string {