hotkey: Close text fields before closing sidebar.

Before this change, we'd try to close the sidebar before
closing text fields. This means if the user sidebar was
open with a text search in progress, pressing Escape
would close the full sidebar instead of closing search.

This change deprioritizes closing the sidebar, in favor
of closing input fields like search.

This also helps with #26717, because the sidebar seems to
be marked as open even when it's not an overlay, which
means pressing Escape will first "close" it (no visual
changes), before a second Escape would trigger closing
the search field. Ideally we differentiate between
situations where we are showing the sidebar as an
overlay and when we aren't, but that might be a more
involved change.
This commit is contained in:
evykassirer
2023-11-02 16:08:02 -07:00
committed by Tim Abbott
parent ac0e03fe89
commit b51da3bb9a

View File

@@ -272,13 +272,12 @@ export function process_escape_key(e) {
return true;
}
if (popovers.any_active() || sidebar_ui.any_sidebar_expanded_as_overlay()) {
if (popovers.any_active()) {
if (user_card_popover.manage_menu.is_open()) {
user_card_popover.manage_menu.hide();
$("#user_card_popover .user-card-popover-manage-menu-btn").trigger("focus");
return true;
}
sidebar_ui.hide_all();
popovers.hide_all();
return true;
}
@@ -350,6 +349,11 @@ export function process_escape_key(e) {
return true;
}
if (sidebar_ui.any_sidebar_expanded_as_overlay()) {
sidebar_ui.hide_all();
return true;
}
if (compose_state.composing()) {
compose_actions.cancel();
return true;