From ac0e03fe8908535b7fb4a60f760ebc287c14faf8 Mon Sep 17 00:00:00 2001 From: evykassirer Date: Thu, 2 Nov 2023 16:22:10 -0700 Subject: [PATCH] user search: Always close widget on escape instead of clearing first. Fixes part of #27491 --- web/src/activity_ui.js | 2 +- web/src/user_search.js | 21 ++++++--------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/web/src/activity_ui.js b/web/src/activity_ui.js index 3b3be2c967..e268ba4a30 100644 --- a/web/src/activity_ui.js +++ b/web/src/activity_ui.js @@ -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(); } } diff --git a/web/src/user_search.js b/web/src/user_search.js index 7627073e00..ffb106dc10 100644 --- a/web/src/user_search.js +++ b/web/src/user_search.js @@ -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();