FIX: Add autofocus to users chooser on the assign modal (#148)

FIX: Add autofocus to users chooser on the assign modal (#148)

The users chooser on the assign modal is the primary input field on the modal, so it makes to shift focus to it when the modal is opened. This PR needs in core to work properly, but it won’t cause errors (won’t have any effects) if it’s deployed to a site that doesn’t have that commit.

diff --git a/assets/javascripts/discourse-assign/controllers/assign-user.js.es6 b/assets/javascripts/discourse-assign/controllers/assign-user.js.es6
index fb7bf22..198e9ee 100644
--- a/assets/javascripts/discourse-assign/controllers/assign-user.js.es6
+++ b/assets/javascripts/discourse-assign/controllers/assign-user.js.es6
@@ -1,12 +1,14 @@
 import { ajax } from "discourse/lib/ajax";
 import { popupAjaxError } from "discourse/lib/ajax-error";
 import { inject as controller } from "@ember/controller";
+import { not } from "@ember/object/computed";
 export default Ember.Controller.extend({
   topicBulkActions: controller(),
   assignSuggestions: null,
   allowedGroups: null,
   taskActions: Ember.inject.service(),
+  autofocus: not("capabilities.touch"),
   init() {
diff --git a/assets/javascripts/discourse/templates/modal/assign-user.hbs b/assets/javascripts/discourse/templates/modal/assign-user.hbs
index 298f993..e84b405 100644
--- a/assets/javascripts/discourse/templates/modal/assign-user.hbs
+++ b/assets/javascripts/discourse/templates/modal/assign-user.hbs
@@ -11,6 +11,7 @@
+        autofocus=autofocus
     <div class="assign-suggestions">

GitHub sha: a90e7ab7

1 Like

This commit appears in #148 which was approved by jjaffeux. It was merged by OsamaSayegh.