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

No test as I don't think it's worth the complexity of a test.
This commit is contained in:
Joffrey JAFFEUX 2022-11-22 08:57:17 +01:00 committed by GitHub
parent d127d2acdf
commit e9863b145c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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;

View File

@ -45,6 +45,7 @@
@filterAction={{action "debouncedFiltering"}}
@icons={{hash right="search"}}
placeholder={{i18n "chat.browse.filter_input_placeholder"}}
{{did-insert (action this.focusFilterInput)}}
/>
</div>