diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 244e88cea..ae7d9df15 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -4386,29 +4386,34 @@ void HistoryWidget::searchInChat() { if (controller()->isPrimary()) { controller()->content()->searchInChat(_history); } else { - const auto update = [=] { - updateControlsVisibility(); - updateBotKeyboard(); - updateFieldPlaceholder(); + const auto search = [=] { + const auto update = [=] { + updateControlsVisibility(); + updateBotKeyboard(); + updateFieldPlaceholder(); - updateControlsGeometry(); - }; - _composeSearch = std::make_unique( - this, - controller(), - _history); - - update(); - setInnerFocus(); - _composeSearch->destroyRequests( - ) | rpl::take( - 1 - ) | rpl::start_with_next([=] { - _composeSearch = nullptr; + updateControlsGeometry(); + }; + _composeSearch = std::make_unique( + this, + controller(), + _history); update(); setInnerFocus(); - }, _composeSearch->lifetime()); + _composeSearch->destroyRequests( + ) | rpl::take( + 1 + ) | rpl::start_with_next([=] { + _composeSearch = nullptr; + + update(); + setInnerFocus(); + }, _composeSearch->lifetime()); + }; + if (!preventsClose(search)) { + search(); + } } }