diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-08-15 19:31:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-15 19:31:48 +0800 |
commit | d317c983bc877d3286f9dc3decb53d534a56a6d0 (patch) | |
tree | c7535cdffa14ce8d703dbf44ff4bce17bbc8136e /web_src/js/features/comp | |
parent | e9d631ec039957d5ea2563285a516c37607c9fc7 (diff) | |
download | gitea-d317c983bc877d3286f9dc3decb53d534a56a6d0.tar.gz gitea-d317c983bc877d3286f9dc3decb53d534a56a6d0.zip |
Set "type=button" for editor's toolbar buttons (#26510)
The editor usually is in a form, so the buttons should have
"type=button", avoid conflicting with the form's submit.
Diffstat (limited to 'web_src/js/features/comp')
-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 d61b6b43cc..9826f2f2bf 100644 --- a/web_src/js/features/comp/ComboMarkdownEditor.js +++ b/web_src/js/features/comp/ComboMarkdownEditor.js @@ -79,6 +79,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'); |