UX: focus category name when editing category (#9795)

UX: focus category name when editing category (#9795)

diff --git a/app/assets/javascripts/discourse/app/components/edit-category-general.js b/app/assets/javascripts/discourse/app/components/edit-category-general.js
index ad9c056..6fc5443 100644
--- a/app/assets/javascripts/discourse/app/components/edit-category-general.js
+++ b/app/assets/javascripts/discourse/app/components/edit-category-general.js
@@ -1,6 +1,7 @@
 import discourseComputed from "discourse-common/utils/decorators";
 import { isEmpty } from "@ember/utils";
 import { not } from "@ember/object/computed";
+import { later } from "@ember/runloop";
 import { buildCategoryPanel } from "discourse/components/edit-category-panel";
 import { categoryBadgeHTML } from "discourse/helpers/category-link";
 import Category from "discourse/models/category";
@@ -12,6 +13,12 @@ export default buildCategoryPanel("general", {
     this.foregroundColors = ["FFFFFF", "000000"];
   },
 
+  didInsertElement() {
+    this._super(...arguments);
+
+    this._focusCategoryName();
+  },
+
   canSelectParentCategory: not("category.isUncategorizedCategory"),
   uncategorizedSiteSettingLink: Discourse.getURL(
     "/admin/site_settings/category/all_results?filter=allow_uncategorized_topics"
@@ -101,5 +108,14 @@ export default buildCategoryPanel("general", {
       window.open(this.get("category.topic_url"), "_blank").focus();
       return false;
     }
+  },
+
+  _focusCategoryName() {
+    later(() => {
+      if (this.element && !this.isDestroying && !this.isDestroyed) {
+        const categoryName = this.element.querySelector(".category-name");
+        categoryName && categoryName.focus();
+      }
+    }, 25);
   }
 });

GitHub sha: 7edd312f

1 Like

This commit appears in #9795 which was approved by eviltrout. It was merged by jjaffeux.