Always show cancel search when focused.

This commit is contained in:
John Preston 2024-04-19 22:04:36 +04:00
parent 34a7169b4f
commit a11535806d
2 changed files with 10 additions and 1 deletions

View File

@ -1109,6 +1109,7 @@ void Widget::updateHasFocus(not_null<QWidget*> focused) {
void Widget::processSearchFocusChange() {
_searchSuggestionsLocked = _suggestions && _suggestions->persist();
updateCancelSearch();
updateStoriesVisibility();
updateForceDisplayWide();
updateSuggestions(anim::type::normal);
@ -2550,6 +2551,13 @@ void Widget::listScrollUpdated() {
_scrollToTop->update();
}
void Widget::updateCancelSearch() {
const auto shown = _searchHasFocus
|| _searchSuggestionsLocked
|| !_search->getLastText().isEmpty();
_cancelSearch->toggle(shown, anim::type::normal);
}
void Widget::applySearchUpdate(bool force) {
if (_showAnimation && !force) {
return;
@ -2562,7 +2570,7 @@ void Widget::applySearchUpdate(bool force) {
if (filterText.isEmpty() && !_searchFromAuthor && _searchTags.empty()) {
clearSearchCache();
}
_cancelSearch->toggle(!filterText.isEmpty(), anim::type::normal);
updateCancelSearch();
if (!_postponeProcessSearchFocusChange) {
updateSuggestions(anim::type::instant);
}

View File

@ -227,6 +227,7 @@ private:
void closeChildList(anim::type animated);
void fullSearchRefreshOn(rpl::producer<> events);
void updateCancelSearch();
void applySearchUpdate(bool force = false);
void refreshLoadMoreButton(bool mayBlock, bool isBlocked);
void loadMoreBlockedByDate();