user search: Always close widget on escape instead of clearing first.

Fixes part of #27491
This commit is contained in:
evykassirer 2023-11-02 16:22:10 -07:00 committed by Tim Abbott
parent a764a3e66f
commit ac0e03fe89
2 changed files with 7 additions and 16 deletions

View File

@ -217,7 +217,7 @@ export function initiate_search() {
export function escape_search() {
if (user_filter) {
user_filter.escape_search();
user_filter.clear_and_hide_search();
}
}

View File

@ -44,6 +44,8 @@ export class UserSearch {
return this.text() === "";
}
// This clears search input but doesn't close
// the search widget unless it was already empty.
clear_search() {
buddy_data.set_is_searching_users(false);
@ -57,14 +59,11 @@ export class UserSearch {
this._reset_items();
}
escape_search() {
if (this.empty()) {
this.close_widget();
return;
}
this.$input.val("");
// This always clears and closes search.
clear_and_hide_search() {
this.clear_search();
this._update_list();
this.close_widget();
}
hide_widget() {
@ -83,14 +82,6 @@ export class UserSearch {
return this.$widget.hasClass("notdisplayed");
}
clear_and_hide_search() {
if (!this.empty()) {
this.$input.val("");
this._update_list();
}
this.close_widget();
}
close_widget() {
this.$input.trigger("blur");
this.hide_widget();