mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 21:11:55 +08:00
Fix submitting TagDiscussionModal via enter key
The DOM submit method doesn't raise a `submit` event (https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit), so submitting the form this way just refreshed the page (default HTML form behavior). The recommended fix (and the one implemented here) is to simulate a button-triggered submission. Fixes https://github.com/flarum/core/issues/2595
This commit is contained in:
parent
7f14e72626
commit
9c77d677c6
|
@ -247,7 +247,9 @@ export default class TagDiscussionModal extends Modal {
|
|||
// Ctrl + Enter submits the selection, just Enter completes the current entry
|
||||
if (e.metaKey || e.ctrlKey || this.selected.indexOf(this.index) !== -1) {
|
||||
if (this.selected.length) {
|
||||
this.$('form').submit();
|
||||
// The DOM submit method doesn't emit a `submit event, so we
|
||||
// simulate a manual submission so our `onsubmit` logic is run.
|
||||
this.$('button[type="submit"]').click();
|
||||
}
|
||||
} else {
|
||||
this.getItem(this.index)[0].dispatchEvent(new Event('click'));
|
||||
|
|
Loading…
Reference in New Issue
Block a user