diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp index 700e8dfba8..d9068495fa 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp @@ -718,6 +718,20 @@ object_ptr EmojiListWidget::createFooter() { return result; } +void EmojiListWidget::afterShown() { + const auto steal = (_mode == Mode::EmojiStatus) + || (_mode == Mode::FullReactions); + if (_search && steal) { + _search->stealFocus(); + } +} + +void EmojiListWidget::beforeHiding() { + if (_search) { + _search->returnFocus(); + } +} + template bool EmojiListWidget::enumerateSections(Callback callback) const { Expects(_columnCount > 0); @@ -2153,6 +2167,10 @@ void EmojiListWidget::refreshEmoji() { void EmojiListWidget::showSet(uint64 setId) { clearSelection(); + if (_search && _searchMode) { + _search->cancel(); + applyNextSearchQuery(); + } auto y = 0; enumerateSections([&](const SectionInfo &info) { diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h index ab8ca1b85c..990515dafb 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h @@ -102,6 +102,9 @@ public: void clearSelection() override; object_ptr createFooter() override; + void afterShown() override; + void beforeHiding() override; + void showSet(uint64 setId); [[nodiscard]] uint64 currentSet(int yOffset) const; void setAllowWithoutPremium(bool allow); diff --git a/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.cpp b/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.cpp index 40a0fa5913..feb4250511 100644 --- a/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.cpp +++ b/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.cpp @@ -282,6 +282,12 @@ void Selector::initGeometry(int innerTop) { } } +void Selector::beforeDestroy() { + if (_list) { + _list->beforeHiding(); + } +} + void Selector::updateShowState( float64 progress, float64 opacity, @@ -531,6 +537,7 @@ void Selector::finishExpand() { _footer->show(); } _scroll->show(); + _list->afterShown(); if (const auto controller = _parentController.get()) { controller->session().api().updateCustomEmoji(); @@ -940,6 +947,12 @@ AttachSelectorResult MakeJustSelectorMenu( } const auto selectorInnerTop = menu->preparedPadding().top() - st::reactStripExtend.top(); + menu->animatePhaseValue( + ) | rpl::start_with_next([=](Ui::PopupMenu::AnimatePhase phase) { + if (phase == Ui::PopupMenu::AnimatePhase::StartHide) { + selector->beforeDestroy(); + } + }, selector->lifetime()); selector->initGeometry(selectorInnerTop); selector->show(); @@ -1005,6 +1018,12 @@ AttachSelectorResult AttachSelectorToMenu( const auto selectorInnerTop = selector->useTransparency() ? (menu->preparedPadding().top() - st::reactStripExtend.top()) : st::lineWidth; + menu->animatePhaseValue( + ) | rpl::start_with_next([=](Ui::PopupMenu::AnimatePhase phase) { + if (phase == Ui::PopupMenu::AnimatePhase::StartHide) { + selector->beforeDestroy(); + } + }, selector->lifetime()); selector->initGeometry(selectorInnerTop); selector->show(); diff --git a/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.h b/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.h index f13907880d..6e6d119cd3 100644 --- a/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.h +++ b/Telegram/SourceFiles/history/view/reactions/history_view_reactions_selector.h @@ -60,6 +60,7 @@ public: [[nodiscard]] int minimalHeight() const; void setSpecialExpandTopSkip(int skip); void initGeometry(int innerTop); + void beforeDestroy(); [[nodiscard]] rpl::producer chosen() const { return _chosen.events(); diff --git a/Telegram/SourceFiles/ui/controls/tabbed_search.cpp b/Telegram/SourceFiles/ui/controls/tabbed_search.cpp index f7f0fe80e6..a0de7decbd 100644 --- a/Telegram/SourceFiles/ui/controls/tabbed_search.cpp +++ b/Telegram/SourceFiles/ui/controls/tabbed_search.cpp @@ -526,6 +526,12 @@ auto SearchWithGroups::debouncedQueryValue() const return _debouncedQuery.value(); } +void SearchWithGroups::cancel() { + _field->setText(QString()); + _chosenGroup = QString(); + scrollGroupsToStart(); +} + void SearchWithGroups::setLoading(bool loading) { _cancel->setLoadingAnimation(loading); } @@ -637,6 +643,10 @@ QImage TabbedSearch::grab() { return Ui::GrabWidgetToImage(&_search); } +void TabbedSearch::cancel() { + _search.cancel(); +} + void TabbedSearch::setLoading(bool loading) { _search.setLoading(loading); } diff --git a/Telegram/SourceFiles/ui/controls/tabbed_search.h b/Telegram/SourceFiles/ui/controls/tabbed_search.h index cc6682f721..81cd913e13 100644 --- a/Telegram/SourceFiles/ui/controls/tabbed_search.h +++ b/Telegram/SourceFiles/ui/controls/tabbed_search.h @@ -53,6 +53,7 @@ public: [[nodiscard]] auto debouncedQueryValue() const -> rpl::producer>; + void cancel(); void setLoading(bool loading); void stealFocus(); void returnFocus(); @@ -118,6 +119,7 @@ public: [[nodiscard]] auto debouncedQueryValue() const ->rpl::producer>; + void cancel(); void setLoading(bool loading); void stealFocus(); void returnFocus(); diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 41ee2fb0f0..43e9128014 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 41ee2fb0f05908112c0cd132c7ab7168ba87fe0c +Subproject commit 43e9128014c5239a6732ae34bdfe007efb9692c8