Skip to content

Commit d317c98

Browse files
authored
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.
1 parent e9d631e commit d317c98

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
@@ -79,6 +79,8 @@ class ComboMarkdownEditor {
7979
for (const el of this.textareaMarkdownToolbar.querySelectorAll('.markdown-toolbar-button')) {
8080
// upstream bug: The role code is never executed in base MarkdownButtonElement https://github.com/github/markdown-toolbar-element/issues/70
8181
el.setAttribute('role', 'button');
82+
// the editor usually is in a form, so the buttons should have "type=button", avoiding conflicting with the form's submit.
83+
if (el.nodeName === 'BUTTON' && !el.getAttribute('type')) el.setAttribute('type', 'button');
8284
}
8385

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

0 commit comments

Comments
 (0)