Skip to content

Commit 31208fe

Browse files
GiteaBotwxiaoguang
andauthored
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 <[email protected]>
1 parent 4bdb8dd commit 31208fe

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

web_src/js/features/comp/ComboMarkdownEditor.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class ComboMarkdownEditor {
7878
for (const el of this.textareaMarkdownToolbar.querySelectorAll('.markdown-toolbar-button')) {
7979
// upstream bug: The role code is never executed in base MarkdownButtonElement https://github.com/github/markdown-toolbar-element/issues/70
8080
el.setAttribute('role', 'button');
81+
// the editor usually is in a form, so the buttons should have "type=button", avoiding conflicting with the form's submit.
82+
if (el.nodeName === 'BUTTON' && !el.getAttribute('type')) el.setAttribute('type', 'button');
8183
}
8284

8385
const monospaceButton = this.container.querySelector('.markdown-switch-monospace');

0 commit comments

Comments
 (0)