Skip to content

Commit

Permalink
Fix: Fixed issue where tab headers sometimes didn't match actual cont…
Browse files Browse the repository at this point in the history
…ent (#13326)
  • Loading branch information
hishitetsu authored Sep 4, 2023
1 parent 6d7fa03 commit 4df04e9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/Files.App/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,31 @@ public async Task UpdateInstanceProperties(object navigationArg)
public async Task UpdateTabInfo(TabItem tabItem, object navigationArg)
{
tabItem.AllowStorageItemDrop = true;

(string, IconSource, string) result = (null, null, null);
if (navigationArg is PaneNavigationArguments paneArgs)
{
if (!string.IsNullOrEmpty(paneArgs.LeftPaneNavPathParam) && !string.IsNullOrEmpty(paneArgs.RightPaneNavPathParam))
{
var leftTabInfo = await GetSelectedTabInfoAsync(paneArgs.LeftPaneNavPathParam);
var rightTabInfo = await GetSelectedTabInfoAsync(paneArgs.RightPaneNavPathParam);
tabItem.Header = $"{leftTabInfo.tabLocationHeader} | {rightTabInfo.tabLocationHeader}";
tabItem.IconSource = leftTabInfo.tabIcon;
result = ($"{leftTabInfo.tabLocationHeader} | {rightTabInfo.tabLocationHeader}",
leftTabInfo.tabIcon,
$"{leftTabInfo.toolTipText} | {rightTabInfo.toolTipText}");
}
else
{
(tabItem.Header, tabItem.IconSource, tabItem.ToolTipText) = await GetSelectedTabInfoAsync(paneArgs.LeftPaneNavPathParam);
result = await GetSelectedTabInfoAsync(paneArgs.LeftPaneNavPathParam);
}
}
else if (navigationArg is string pathArgs)
{
(tabItem.Header, tabItem.IconSource, tabItem.ToolTipText) = await GetSelectedTabInfoAsync(pathArgs);
result = await GetSelectedTabInfoAsync(pathArgs);
}

// Don't update tabItem if the contents of the tab have already changed
if (result.Item1 is not null && navigationArg == tabItem.TabItemArguments.NavigationArg)
(tabItem.Header, tabItem.IconSource, tabItem.ToolTipText) = result;
}

public async Task<(string tabLocationHeader, IconSource tabIcon, string toolTipText)> GetSelectedTabInfoAsync(string currentPath)
Expand Down

0 comments on commit 4df04e9

Please sign in to comment.