Skip to content

Commit ad9ae14

Browse files
authored
Fix: Fixed opening a tag from sidebar in a new tab (#10665)
1 parent 45cdfde commit ad9ae14

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

src/Files.App/Helpers/ContextFlyoutItemHelper.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseLayoutMenuItems(Curren
538538
Text = "BaseLayoutItemContextFlyoutPinToFavorites/Text".GetLocalizedResource(),
539539
Glyph = "\uE840",
540540
Command = commandsViewModel.PinDirectoryToFavoritesCommand,
541-
ShowItem = !itemViewModel.CurrentFolder.IsPinned & userSettingsService.AppearanceSettingsService.ShowFavoritesSection,
541+
ShowItem = itemViewModel.CurrentFolder is not null && !itemViewModel.CurrentFolder.IsPinned & userSettingsService.AppearanceSettingsService.ShowFavoritesSection,
542542
ShowInFtpPage = true,
543543
ShowInRecycleBin = true,
544544
},
@@ -547,7 +547,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseLayoutMenuItems(Curren
547547
Text = "BaseLayoutContextFlyoutUnpinFromFavorites/Text".GetLocalizedResource(),
548548
Glyph = "\uE77A",
549549
Command = commandsViewModel.UnpinDirectoryFromFavoritesCommand,
550-
ShowItem = itemViewModel.CurrentFolder.IsPinned & userSettingsService.AppearanceSettingsService.ShowFavoritesSection,
550+
ShowItem = itemViewModel.CurrentFolder is not null && itemViewModel.CurrentFolder.IsPinned & userSettingsService.AppearanceSettingsService.ShowFavoritesSection,
551551
ShowInFtpPage = true,
552552
ShowInRecycleBin = true,
553553
},
@@ -558,7 +558,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseLayoutMenuItems(Curren
558558
Command = commandsViewModel.PinItemToStartCommand,
559559
ShowInFtpPage = true,
560560
ShowOnShift = true,
561-
ShowItem = !itemViewModel.CurrentFolder.IsItemPinnedToStart,
561+
ShowItem = itemViewModel.CurrentFolder is not null && !itemViewModel.CurrentFolder.IsItemPinnedToStart,
562562
},
563563
new ContextMenuFlyoutItemViewModel()
564564
{
@@ -567,7 +567,7 @@ public static List<ContextMenuFlyoutItemViewModel> GetBaseLayoutMenuItems(Curren
567567
Command = commandsViewModel.UnpinItemFromStartCommand,
568568
ShowInFtpPage = true,
569569
ShowOnShift = true,
570-
ShowItem = itemViewModel.CurrentFolder.IsItemPinnedToStart,
570+
ShowItem = itemViewModel.CurrentFolder is not null && itemViewModel.CurrentFolder.IsItemPinnedToStart,
571571
},
572572
new ContextMenuFlyoutItemViewModel()
573573
{

src/Files.App/Views/ModernShellPage.xaml.cs

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ public bool IsCurrentInstance
7777

7878
public bool IsColumnView => SlimContentPage is ColumnViewBrowser;
7979

80-
public ItemViewModel FilesystemViewModel { get; private set; } = null;
80+
public ItemViewModel FilesystemViewModel { get; private set; }
8181
public CurrentInstanceViewModel InstanceViewModel { get; }
82-
private BaseLayout contentPage = null;
8382

83+
private BaseLayout contentPage;
8484
public BaseLayout ContentPage
8585
{
8686
get => contentPage;
@@ -96,7 +96,6 @@ public BaseLayout ContentPage
9696
}
9797

9898
private bool isPageMainPane;
99-
10099
public bool IsPageMainPane
101100
{
102101
get => isPageMainPane;
@@ -143,6 +142,13 @@ public ModernShellPage()
143142
FilesystemHelpers = new FilesystemHelpers(this, cancellationTokenSource.Token);
144143
storageHistoryHelpers = new StorageHistoryHelpers(new StorageHistoryOperations(this, cancellationTokenSource.Token));
145144

145+
FilesystemViewModel = new ItemViewModel(InstanceViewModel.FolderSettings);
146+
FilesystemViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified;
147+
FilesystemViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged;
148+
FilesystemViewModel.DirectoryInfoUpdated += FilesystemViewModel_DirectoryInfoUpdated;
149+
FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated;
150+
FilesystemViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent;
151+
146152
ToolbarViewModel.SearchBox.TextChanged += ModernShellPage_TextChanged;
147153
ToolbarViewModel.SearchBox.QuerySubmitted += ModernShellPage_QuerySubmitted;
148154
ToolbarViewModel.InstanceViewModel = InstanceViewModel;
@@ -514,20 +520,29 @@ public NavigationParams NavParams
514520
private void OnNavigationParamsChanged()
515521
{
516522
if (string.IsNullOrEmpty(NavParams?.NavPath) || NavParams.NavPath == "Home".GetLocalizedResource())
523+
{
517524
ItemDisplayFrame.Navigate(typeof(WidgetsPage),
518525
new NavigationArguments()
519526
{
520527
NavPathParam = NavParams?.NavPath,
521528
AssociatedTabInstance = this
522529
}, new EntranceNavigationTransitionInfo());
530+
}
523531
else
532+
{
533+
var isTagSearch = NavParams.NavPath.StartsWith("tag:");
534+
524535
ItemDisplayFrame.Navigate(InstanceViewModel.FolderSettings.GetLayoutType(NavParams.NavPath),
525536
new NavigationArguments()
526537
{
527538
NavPathParam = NavParams.NavPath,
528539
SelectItems = !string.IsNullOrWhiteSpace(NavParams?.SelectItem) ? new[] { NavParams.SelectItem } : null,
540+
IsSearchResultPage = isTagSearch,
541+
SearchPathParam = isTagSearch ? "Home".GetLocalizedResource() : null,
542+
SearchQuery = isTagSearch ? navParams.NavPath : null,
529543
AssociatedTabInstance = this
530544
});
545+
}
531546
}
532547

533548
public static readonly DependencyProperty NavParamsProperty =
@@ -574,12 +589,6 @@ private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
574589

575590
private void Page_Loaded(object sender, RoutedEventArgs e)
576591
{
577-
FilesystemViewModel = new ItemViewModel(InstanceViewModel?.FolderSettings);
578-
FilesystemViewModel.WorkingDirectoryModified += ViewModel_WorkingDirectoryModified;
579-
FilesystemViewModel.ItemLoadStatusChanged += FilesystemViewModel_ItemLoadStatusChanged;
580-
FilesystemViewModel.DirectoryInfoUpdated += FilesystemViewModel_DirectoryInfoUpdated;
581-
FilesystemViewModel.PageTypeUpdated += FilesystemViewModel_PageTypeUpdated;
582-
FilesystemViewModel.OnSelectionRequestedEvent += FilesystemViewModel_OnSelectionRequestedEvent;
583592
OnNavigationParamsChanged();
584593
this.Loaded -= Page_Loaded;
585594
}

src/Files.App/Views/PaneHolderPage.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ private void Pane_ContentChanged(object sender, TabItemArguments e)
271271
InitialPageType = typeof(PaneHolderPage),
272272
NavigationArg = new PaneNavigationArguments()
273273
{
274-
LeftPaneNavPathParam = e?.NavigationArg as string ?? PaneLeft.TabItemArguments?.NavigationArg as string,
274+
LeftPaneNavPathParam = PaneLeft.TabItemArguments?.NavigationArg as string ?? e?.NavigationArg as string,
275275
RightPaneNavPathParam = IsRightPaneVisible ? PaneRight?.TabItemArguments?.NavigationArg as string : null
276276
}
277277
};

0 commit comments

Comments
 (0)