Skip to content

Commit 17e6c46

Browse files
committed
Fixed BrowserPage navigation stack tracking
1 parent 4af3db5 commit 17e6c46

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/Platforms/SecureFolderFS.Maui/Views/Vault/BrowserPage.xaml.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ public async Task<bool> GoBackAsync()
5353
if (ViewModel?.InnerNavigator is not MauiNavigationService navigationService)
5454
return false;
5555

56+
// Already at the bottom of the navigation stack, return false
5657
var index = navigationService.IndexInNavigation;
57-
if (navigationService.Views[Math.Max(--index, 0)] is not FolderViewModel folderViewModel)
58+
if (index <= 0)
59+
return false;
60+
61+
if (navigationService.Views[index - 1] is not FolderViewModel folderViewModel)
5862
return false;
5963

6064
// Remove the last navigated-to breadcrumb
@@ -78,8 +82,12 @@ public async Task<bool> GoForwardAsync()
7882
if (ViewModel?.InnerNavigator is not MauiNavigationService navigationService)
7983
return false;
8084

85+
// Already at the top of the navigation stack, return false
8186
var index = navigationService.IndexInNavigation;
82-
if (navigationService.Views[Math.Min(++index, Math.Max(navigationService.Views.Count, 0))] is not FolderViewModel folderViewModel)
87+
if (index + 1 >= navigationService.Views.Count)
88+
return false;
89+
90+
if (navigationService.Views[index + 1] is not FolderViewModel folderViewModel)
8391
return false;
8492

8593
// Animate navigation

0 commit comments

Comments
 (0)