Skip to content

Commit

Permalink
Set "type=button" for editor's toolbar buttons (#26510) (#26518)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
GiteaBot and wxiaoguang authored Aug 15, 2023
1 parent 4bdb8dd commit 31208fe
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions web_src/js/features/comp/ComboMarkdownEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 31208fe

Please sign in to comment.