Skip to content

Commit

Permalink
Fix: Fixed issue where tooltip in details layout was displaying the w…
Browse files Browse the repository at this point in the history
…rong data (#12610)
  • Loading branch information
hishitetsu authored and yaira2 committed Jun 14, 2023
1 parent 3f66a8d commit 68a710a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@
x:Name="ItemName"
Padding="6,0,0,0"
VerticalAlignment="Center"
DataContextChanged="TextBlock_DataContextChanged"
IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged"
Opacity="{x:Bind Opacity, Mode=OneWay}"
Text="{x:Bind Name, Mode=OneWay}"
Expand Down Expand Up @@ -722,6 +723,7 @@
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
x:Load="{x:Bind IsRecycleBinItem}"
DataContextChanged="TextBlock_DataContextChanged"
IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind AsRecycleBinItem.ItemOriginalPath, Mode=OneWay}"
Expand All @@ -734,6 +736,7 @@
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
x:Load="{x:Bind IsRecycleBinItem}"
DataContextChanged="TextBlock_DataContextChanged"
IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind AsRecycleBinItem.ItemDateDeleted, Mode=OneWay}"
Expand All @@ -745,6 +748,7 @@
Padding="10,0,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
DataContextChanged="TextBlock_DataContextChanged"
IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind ItemDateModified, Mode=OneWay}"
Expand All @@ -756,6 +760,7 @@
Padding="10,0,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
DataContextChanged="TextBlock_DataContextChanged"
IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind ItemDateCreated, Mode=OneWay}"
Expand All @@ -767,6 +772,7 @@
Padding="10,0,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
DataContextChanged="TextBlock_DataContextChanged"
IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind ItemType, Mode=OneWay}"
Expand All @@ -778,6 +784,7 @@
Padding="10,0,0,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
DataContextChanged="TextBlock_DataContextChanged"
IsTextTrimmedChanged="TextBlock_IsTextTrimmedChanged"
Style="{StaticResource ColumnContentTextBlock}"
Text="{x:Bind FileSize, Mode=OneWay}"
Expand Down
13 changes: 12 additions & 1 deletion src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,18 @@ private void UpdateCheckboxVisibility(object sender, bool isPointerOver)
// Workaround for https://github.com/microsoft/microsoft-ui-xaml/issues/170
private void TextBlock_IsTextTrimmedChanged(TextBlock sender, IsTextTrimmedChangedEventArgs e)
{
ToolTipService.SetToolTip(sender, sender.IsTextTrimmed ? sender.Text : null);
SetToolTip(sender);
}

private void TextBlock_DataContextChanged(FrameworkElement sender, DataContextChangedEventArgs e)
{
if (sender is TextBlock textBlock)
SetToolTip(textBlock);
}

private void SetToolTip(TextBlock textBlock)
{
ToolTipService.SetToolTip(textBlock, textBlock.IsTextTrimmed ? textBlock.Text : null);
}
}
}

0 comments on commit 68a710a

Please sign in to comment.