diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_section.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_section.cpp index 3759697e33..92f6aaa007 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_section.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_section.cpp @@ -28,6 +28,9 @@ TabbedSection::TabbedSection( not_null controller) : Window::SectionWidget(parent, controller) , _selector(controller->tabbedSelector()) { + if (Ui::InFocusChain(_selector)) { + parent->window()->setFocus(); + } _selector->setParent(this); _selector->setRoundRadius(0); _selector->setGeometry(rect()); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index c9acfef927..4dd47970df 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1772,7 +1772,7 @@ void MainWidget::showNewSection( _thirdSection = std::move(newThirdSection); _thirdSection->removeRequests( ) | rpl::start_with_next([=] { - _thirdSection.destroy(); + destroyThirdSection(); _thirdShadow.destroy(); updateControlsGeometry(); }, _thirdSection->lifetime()); @@ -2289,7 +2289,7 @@ void MainWidget::updateControlsGeometry() { } } } else { - _thirdSection.destroy(); + destroyThirdSection(); _thirdShadow.destroy(); } const auto mainSectionTop = getMainSectionTop(); @@ -2408,6 +2408,15 @@ void MainWidget::updateControlsGeometry() { floatPlayerUpdatePositions(); } +void MainWidget::destroyThirdSection() { + if (const auto strong = _thirdSection.data()) { + if (Ui::InFocusChain(strong)) { + setFocus(); + } + } + _thirdSection.destroy(); +} + void MainWidget::refreshResizeAreas() { if (!isOneColumn() && _dialogs) { ensureFirstColumnResizeAreaCreated(); @@ -2555,7 +2564,7 @@ void MainWidget::updateThirdColumnToCurrentChat( if (saveThirdSectionToStackBack()) { _stack.back()->setThirdSectionMemento( _thirdSection->createMemento()); - _thirdSection.destroy(); + destroyThirdSection(); } }; auto &settings = Core::App().settings(); @@ -2601,7 +2610,7 @@ void MainWidget::updateThirdColumnToCurrentChat( settings.setTabbedReplacedWithInfo(false); if (!key) { if (_thirdSection) { - _thirdSection.destroy(); + destroyThirdSection(); _thirdShadow.destroy(); updateControlsGeometry(); } diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 0f769a53f3..14e1ef2abe 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -279,6 +279,7 @@ private: void showNewSection( std::shared_ptr memento, const SectionShow ¶ms); + void destroyThirdSection(); Window::SectionSlideParams prepareThirdSectionAnimation(Window::SectionWidget *section);