FEATURE: Allow submitting the assign modal with ctrl+enter (#362)

This commit allows submitting the assign modal with
control/meta+enter when the textarea is focused.
This commit is contained in:
Martin Brennan 2022-07-28 16:18:44 +10:00 committed by GitHub
parent 02e76e4986
commit a29a02abe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import Controller, { inject as controller } from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { action } from "@ember/object";
import { not, or } from "@ember/object/computed";
import { inject as service } from "@ember/service";
@ -6,7 +7,7 @@ import { isEmpty } from "@ember/utils";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Controller.extend({
export default Controller.extend(ModalFunctionality, {
topicBulkActions: controller(),
assignSuggestions: null,
allowedGroups: null,
@ -41,6 +42,13 @@ export default Controller.extend({
});
},
@action
handleTextAreaKeydown(value, event) {
if ((event.ctrlKey || event.metaKey) && event.key === "Enter") {
this.assign();
}
},
@action
assign() {
if (this.isBulkAction) {

View File

@ -26,7 +26,7 @@
{{/each}}
</div>
<label>{{i18n "discourse_assign.assign_modal.note_label"}}</label>
{{textarea value=model.note}}
{{textarea id="assign-modal-note" value=model.note key-down=(action "handleTextAreaKeydown")}}
</div>
{{/d-modal-body}}