search: Don't use e.target for the query click handler.

This is preparation for search pills.

The X button for user pills will be a click target
that disappears from the DOM. We don't want to
look for the parent of a click element that might
not exist, since that would give us a false positive
and lead us to reset the search bar when removing a
user pill. This commit brings this click handler to
a more stable state.
This commit is contained in:
evykassirer 2024-05-08 20:47:32 -07:00 committed by Tim Abbott
parent 1045e322fd
commit 20e4778163
1 changed files with 2 additions and 2 deletions

View File

@ -172,8 +172,8 @@ export function initialize({on_narrow_search}: {on_narrow_search: OnNarrowSearch
// when an option is selected and we're closing search).
// Instead we explicitly initiate search on click and on specific keyboard
// shortcuts.
$search_query_box.on("click", (e: JQuery.ClickEvent): void => {
if ($(e.target).parents(".navbar-search.expanded").length === 0) {
$search_query_box.on("click", (): void => {
if ($("#searchbox .navbar-search.expanded").length === 0) {
initiate_search();
}
});