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)
: Window::SectionWidget(parent, controller)
, _selector(controller->tabbedSelector()) {
if (Ui::InFocusChain(_selector)) {
parent->window()->setFocus();
}
_selector->setParent(this);
_selector->setRoundRadius(0);
_selector->setGeometry(rect());

View File

@ -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();
}

View File

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