Skip to content

Commit 59be516

Browse files
Feature: Scroll to the selected file when using "Open file location" (#13133)
1 parent 2dfdd3f commit 59be516

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/Files.App/Views/LayoutModes/ColumnViewBrowser.xaml.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
114114
SearchQuery = navigationArguments.SearchQuery,
115115
SearchUnindexedItems = navigationArguments.SearchUnindexedItems,
116116
SearchPathParam = navigationArguments.SearchPathParam,
117-
NavPathParam = path
117+
NavPathParam = path,
118+
SelectItems = path == navigationArguments.NavPathParam? navigationArguments.SelectItems : null
118119
});
119120

120121
var index = 0;
@@ -125,7 +126,8 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
125126
frame.Navigate(typeof(ColumnShellPage), new ColumnParam
126127
{
127128
Column = ++index,
128-
NavPathParam = path
129+
NavPathParam = path,
130+
SelectItems = path == navigationArguments.NavPathParam? navigationArguments.SelectItems : null
129131
});
130132
}
131133
}

src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ protected override void ItemManipulationModel_ScrollIntoViewInvoked(object? send
7272

7373
protected override void ItemManipulationModel_FocusSelectedItemsInvoked(object? sender, EventArgs e)
7474
{
75-
if (SelectedItems.Any())
75+
if (SelectedItems?.Any() ?? false)
7676
{
7777
FileList.ScrollIntoView(SelectedItems.Last());
78+
ContentScroller?.ChangeView(null, FileList.Items.IndexOf(SelectedItems.Last()) * Convert.ToInt32(Application.Current.Resources["ListItemHeight"]), null, false);
7879
(FileList.ContainerFromItem(SelectedItems.Last()) as ListViewItem)?.Focus(FocusState.Keyboard);
7980
}
8081
}

src/Files.App/Views/Shells/ColumnShellPage.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ protected override void OnNavigationParamsChanged()
6666
NavPathParam = ColumnParams.NavPathParam,
6767
SearchUnindexedItems = ColumnParams.SearchUnindexedItems,
6868
SearchPathParam = ColumnParams.SearchPathParam,
69-
AssociatedTabInstance = this
69+
AssociatedTabInstance = this,
70+
SelectItems = ColumnParams.SelectItems
7071
});
7172
}
7273

0 commit comments

Comments
 (0)