diff --git a/src/Files.App/Views/ShellPanesPage.xaml.cs b/src/Files.App/Views/ShellPanesPage.xaml.cs index 293e61616f42..cb45e91ecd94 100644 --- a/src/Files.App/Views/ShellPanesPage.xaml.cs +++ b/src/Files.App/Views/ShellPanesPage.xaml.cs @@ -32,6 +32,7 @@ public sealed partial class ShellPanesPage : Page, IShellPanesPage, ITabBarItemC // Fields private bool _wasRightPaneVisible; + private NavigationParams? _savedNavParamsRight; // Properties @@ -105,8 +106,12 @@ public bool WindowIsCompact // Close pane _wasRightPaneVisible = GetPaneCount() >= 2; - if (GetPaneCount() >= 2) + if (_wasRightPaneVisible) + { + var currentPath = GetPane(1)?.TabBarItemParameter?.NavigationParameter as string ?? "Home"; + _savedNavParamsRight = new NavigationParams { NavPath = currentPath }; RemovePane(1); + } } else if (_wasRightPaneVisible) { @@ -114,6 +119,12 @@ public bool WindowIsCompact if (GetPaneCount() == 1) AddPane(); + if (_savedNavParamsRight is not null) + { + NavParamsRight = _savedNavParamsRight; + _savedNavParamsRight = null; + } + _wasRightPaneVisible = false; }