From d5ae9bcba20a05c560ba9b1ae42aa420da3f10a4 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Tue, 26 Dec 2017 16:55:15 +0300
Subject: [PATCH] Close box when showing a layer section from it.

---
 Telegram/SourceFiles/mainwidget.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp
index 97b557f72..f6357c327 100644
--- a/Telegram/SourceFiles/mainwidget.cpp
+++ b/Telegram/SourceFiles/mainwidget.cpp
@@ -2645,11 +2645,12 @@ void MainWidget::showNewSection(
 		: nullptr;
 	if (newThirdSection) {
 		saveInStack = false;
-	} else {
-		if (auto layer = memento.createLayer(_controller, rect())) {
-			_controller->showSpecialLayer(std::move(layer));
-			return;
+	} else if (auto layer = memento.createLayer(_controller, rect())) {
+		if (params.activation != anim::activation::background) {
+			Ui::hideLayer(anim::type::instant);
 		}
+		_controller->showSpecialLayer(std::move(layer));
+		return;
 	}
 
 	if (params.activation != anim::activation::background) {