Fix collections filter not hiding on windows (#3850)

On windows, if the cross icon from the collection filter
search-textbox is clicked, the 'blur' event fires before
the input is cleared, and the filter is never hidden.
To make sure that the search field ends up going away,
hide it if the field is empty and not focused in input
handler.

Fixes: #3840
This commit is contained in:
abaevbog 2024-03-15 03:37:42 -04:00 committed by GitHub
parent eb2ef8a2d1
commit e5dd25fbd5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2858,6 +2858,12 @@ var ZoteroPane = new function()
this.handleCollectionSearchInput = function () {
let collectionsSearchField = document.getElementById("zotero-collections-search");
this.collectionsView.setFilter(collectionsSearchField.value);
// Make sure that the filter ends up being hidden if the value is cleared
// after the blur event fires. This happens on windows on cross icon click.
if (collectionsSearchField.value.length == 0
&& document.activeElement !== collectionsSearchField) {
this.hideCollectionSearch();
}
}