Skip to content

A platform for community discussion. Free, open, simple.

UX: ensures browse view input is focused on page load (#19137)

Joffrey JAFFEUXe9863b145cb0
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-browse-view.js b/plugins/chat/assets/javascripts/discourse/components/chat-browse-view.js
index 4de9c91b2c8..a9d66616cdf 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-browse-view.js
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-browse-view.js
@@ -2,6 +2,7 @@ import { INPUT_DELAY } from "discourse-common/config/environment";
import Component from "@ember/component";
import { action, computed } from "@ember/object";
import { tracked } from "@glimmer/tracking";
+import { schedule } from "@ember/runloop";
import { inject as service } from "@ember/service";
import ChatApi from "discourse/plugins/chat/discourse/lib/chat-api";
import discourseDebounce from "discourse-common/lib/debounce";
@@ -95,6 +96,11 @@ export default class ChatBrowseView extends Component {
showModal("create-channel");
}
+ @action
+ focusFilterInput(input) {
+ schedule("afterRender", () => input?.focus());
+ }
+
@bind
filterChannels(filter) {
this.canLoadMore = true;
diff --git a/plugins/chat/assets/javascripts/discourse/templates/components/chat-browse-view.hbs b/plugins/chat/assets/javascripts/discourse/templates/components/chat-browse-view.hbs
index b8e659f9923..04b7b31cf6c 100644
--- a/plugins/chat/assets/javascripts/discourse/templates/components/chat-browse-view.hbs
+++ b/plugins/chat/assets/javascripts/discourse/templates/components/chat-browse-view.hbs
@@ -45,6 +45,7 @@
@filterAction={{action "debouncedFiltering"}}
@icons={{hash right="search"}}
placeholder={{i18n "chat.browse.filter_input_placeholder"}}
+ {{did-insert (action this.focusFilterInput)}}
/>
</div>