From a90e7ab7e24c3adb5803c0a955188e2e21e7762e Mon Sep 17 00:00:00 2001 From: Osama Sayegh Date: Tue, 23 Feb 2021 14:05:34 +0300 Subject: [PATCH] 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 https://github.com/discourse/discourse/commit/0f807ba85b869fffc9560d97632d3ca7471e7fc4 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. --- .../javascripts/discourse-assign/controllers/assign-user.js.es6 | 2 ++ assets/javascripts/discourse/templates/modal/assign-user.hbs | 1 + 2 files changed, 3 insertions(+) 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() { this._super(...arguments); 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 @@ includeGroups=false groupMembersOf=allowedGroups maximum=1 + autofocus=autofocus ) }}