diff options
author | Giteabot <teabot@gitea.io> | 2023-08-15 20:10:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-15 14:10:50 +0200 |
commit | 31208fe9a138ae29a114a28155e73b3e9b259ce3 (patch) | |
tree | a1a5d5023cf73fc16e3df0e92c973e94e5542879 /web_src | |
parent | 4bdb8dd9cc028a071819afd8f79cf29b30ab4d30 (diff) | |
download | gitea-31208fe9a138ae29a114a28155e73b3e9b259ce3.tar.gz gitea-31208fe9a138ae29a114a28155e73b3e9b259ce3.zip |
Set "type=button" for editor's toolbar buttons (#26510) (#26518)
Backport #26510 by @wxiaoguang
The editor usually is in a form, so the buttons should have
"type=button", avoid conflicting with the form's submit.
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'web_src')
-rw-r--r-- | web_src/js/features/comp/ComboMarkdownEditor.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/web_src/js/features/comp/ComboMarkdownEditor.js b/web_src/js/features/comp/ComboMarkdownEditor.js index 48e3ca5bd2..4ea7c3e63a 100644 --- a/web_src/js/features/comp/ComboMarkdownEditor.js +++ b/web_src/js/features/comp/ComboMarkdownEditor.js @@ -78,6 +78,8 @@ class ComboMarkdownEditor { for (const el of this.textareaMarkdownToolbar.querySelectorAll('.markdown-toolbar-button')) { // upstream bug: The role code is never executed in base MarkdownButtonElement https://github.com/github/markdown-toolbar-element/issues/70 el.setAttribute('role', 'button'); + // the editor usually is in a form, so the buttons should have "type=button", avoiding conflicting with the form's submit. + if (el.nodeName === 'BUTTON' && !el.getAttribute('type')) el.setAttribute('type', 'button'); } const monospaceButton = this.container.querySelector('.markdown-switch-monospace'); |