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 Controller, { inject as controller } from "@ember/controller";
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { action } from "@ember/object"; import { action } from "@ember/object";
import { not, or } from "@ember/object/computed"; import { not, or } from "@ember/object/computed";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
@ -6,7 +7,7 @@ import { isEmpty } from "@ember/utils";
import { ajax } from "discourse/lib/ajax"; import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error"; import { popupAjaxError } from "discourse/lib/ajax-error";
export default Controller.extend({ export default Controller.extend(ModalFunctionality, {
topicBulkActions: controller(), topicBulkActions: controller(),
assignSuggestions: null, assignSuggestions: null,
allowedGroups: 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 @action
assign() { assign() {
if (this.isBulkAction) { if (this.isBulkAction) {

View File

@ -26,7 +26,7 @@
{{/each}} {{/each}}
</div> </div>
<label>{{i18n "discourse_assign.assign_modal.note_label"}}</label> <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> </div>
{{/d-modal-body}} {{/d-modal-body}}