Fix unintentional search focus.

This commit is contained in:
John Preston 2024-05-29 12:08:22 +04:00
parent a9a0fe7cf5
commit e2b78b673b
3 changed files with 17 additions and 4 deletions

View File

@ -28,6 +28,9 @@ TabbedSection::TabbedSection(
not_null<Window::SessionController*> controller) not_null<Window::SessionController*> controller)
: Window::SectionWidget(parent, controller) : Window::SectionWidget(parent, controller)
, _selector(controller->tabbedSelector()) { , _selector(controller->tabbedSelector()) {
if (Ui::InFocusChain(_selector)) {
parent->window()->setFocus();
}
_selector->setParent(this); _selector->setParent(this);
_selector->setRoundRadius(0); _selector->setRoundRadius(0);
_selector->setGeometry(rect()); _selector->setGeometry(rect());

View File

@ -1772,7 +1772,7 @@ void MainWidget::showNewSection(
_thirdSection = std::move(newThirdSection); _thirdSection = std::move(newThirdSection);
_thirdSection->removeRequests( _thirdSection->removeRequests(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
_thirdSection.destroy(); destroyThirdSection();
_thirdShadow.destroy(); _thirdShadow.destroy();
updateControlsGeometry(); updateControlsGeometry();
}, _thirdSection->lifetime()); }, _thirdSection->lifetime());
@ -2289,7 +2289,7 @@ void MainWidget::updateControlsGeometry() {
} }
} }
} else { } else {
_thirdSection.destroy(); destroyThirdSection();
_thirdShadow.destroy(); _thirdShadow.destroy();
} }
const auto mainSectionTop = getMainSectionTop(); const auto mainSectionTop = getMainSectionTop();
@ -2408,6 +2408,15 @@ void MainWidget::updateControlsGeometry() {
floatPlayerUpdatePositions(); floatPlayerUpdatePositions();
} }
void MainWidget::destroyThirdSection() {
if (const auto strong = _thirdSection.data()) {
if (Ui::InFocusChain(strong)) {
setFocus();
}
}
_thirdSection.destroy();
}
void MainWidget::refreshResizeAreas() { void MainWidget::refreshResizeAreas() {
if (!isOneColumn() && _dialogs) { if (!isOneColumn() && _dialogs) {
ensureFirstColumnResizeAreaCreated(); ensureFirstColumnResizeAreaCreated();
@ -2555,7 +2564,7 @@ void MainWidget::updateThirdColumnToCurrentChat(
if (saveThirdSectionToStackBack()) { if (saveThirdSectionToStackBack()) {
_stack.back()->setThirdSectionMemento( _stack.back()->setThirdSectionMemento(
_thirdSection->createMemento()); _thirdSection->createMemento());
_thirdSection.destroy(); destroyThirdSection();
} }
}; };
auto &settings = Core::App().settings(); auto &settings = Core::App().settings();
@ -2601,7 +2610,7 @@ void MainWidget::updateThirdColumnToCurrentChat(
settings.setTabbedReplacedWithInfo(false); settings.setTabbedReplacedWithInfo(false);
if (!key) { if (!key) {
if (_thirdSection) { if (_thirdSection) {
_thirdSection.destroy(); destroyThirdSection();
_thirdShadow.destroy(); _thirdShadow.destroy();
updateControlsGeometry(); updateControlsGeometry();
} }

View File

@ -279,6 +279,7 @@ private:
void showNewSection( void showNewSection(
std::shared_ptr<Window::SectionMemento> memento, std::shared_ptr<Window::SectionMemento> memento,
const SectionShow &params); const SectionShow &params);
void destroyThirdSection();
Window::SectionSlideParams prepareThirdSectionAnimation(Window::SectionWidget *section); Window::SectionSlideParams prepareThirdSectionAnimation(Window::SectionWidget *section);