From 9c77d677c6ee8ba50b519d9e25c1669460dd0bde Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov Date: Sun, 7 Feb 2021 01:38:39 -0500 Subject: [PATCH] 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 --- extensions/tags/js/src/forum/components/TagDiscussionModal.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extensions/tags/js/src/forum/components/TagDiscussionModal.js b/extensions/tags/js/src/forum/components/TagDiscussionModal.js index 79aed699e..843145dfe 100644 --- a/extensions/tags/js/src/forum/components/TagDiscussionModal.js +++ b/extensions/tags/js/src/forum/components/TagDiscussionModal.js @@ -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'));