Skip to content

Commit 031c35d

Browse files
authored
Fix: Fixed issue where item names in the Tags widget didn't have ellipsis (#12651)
1 parent a2dcb40 commit 031c35d

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

src/Files.App/UserControls/Widgets/FileTagsWidget.xaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
IsItemClickEnabled="True"
9898
ItemClick="FileTagItem_ItemClick"
9999
ItemsSource="{x:Bind Tags}"
100+
RightTapped="AdaptiveGridView_RightTapped"
100101
SelectionMode="None"
101102
StretchContentForSingleRow="False">
102103
<controls:AdaptiveGridView.ItemContainerStyle>
@@ -108,24 +109,30 @@
108109

109110
<controls:AdaptiveGridView.ItemTemplate>
110111
<DataTemplate x:DataType="vm:FileTagsItemViewModel">
111-
<StackPanel
112+
<Grid
113+
ColumnSpacing="8"
112114
DataContext="{x:Bind}"
113-
Orientation="Horizontal"
114-
RightTapped="Item_RightTapped"
115-
Spacing="8">
115+
ToolTipService.ToolTip="{x:Bind Path}">
116+
<Grid.ColumnDefinitions>
117+
<ColumnDefinition Width="Auto" />
118+
<ColumnDefinition Width="*" />
119+
</Grid.ColumnDefinitions>
120+
116121
<!-- Icon -->
117122
<Image
123+
Grid.Column="0"
118124
Width="20"
119125
Height="20"
120126
VerticalAlignment="Center"
121127
Source="{x:Bind Icon, Mode=OneWay, Converter={StaticResource ImageModelToImageConverter}}" />
122128

123129
<!-- Name -->
124130
<TextBlock
131+
Grid.Column="1"
125132
VerticalAlignment="Center"
126133
Text="{x:Bind Name, Mode=OneWay}"
127134
TextTrimming="CharacterEllipsis" />
128-
</StackPanel>
135+
</Grid>
129136
</DataTemplate>
130137
</controls:AdaptiveGridView.ItemTemplate>
131138
</controls:AdaptiveGridView>

src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,13 @@
11
// Copyright (c) 2023 Files Community
22
// Licensed under the MIT License. See the LICENSE.
33

4-
using CommunityToolkit.Mvvm.DependencyInjection;
5-
using CommunityToolkit.Mvvm.Input;
6-
using Files.App.Extensions;
7-
using Files.App.Filesystem;
8-
using Files.App.Helpers;
94
using Files.App.Helpers.ContextFlyouts;
10-
using Files.App.ViewModels;
115
using Files.App.ViewModels.Widgets;
12-
using Files.Backend.Services.Settings;
13-
using Files.Shared.Extensions;
14-
using Microsoft.Extensions.Logging;
156
using Microsoft.UI.Xaml;
167
using Microsoft.UI.Xaml.Controls;
178
using Microsoft.UI.Xaml.Controls.Primitives;
189
using Microsoft.UI.Xaml.Input;
19-
using System;
20-
using System.Collections.Generic;
2110
using System.IO;
22-
using System.Linq;
23-
using System.Threading.Tasks;
2411
using System.Windows.Input;
2512
using Windows.Storage;
2613

@@ -109,15 +96,13 @@ private async void FileTagItem_ItemClick(object sender, ItemClickEventArgs e)
10996
await itemViewModel.ClickCommand.ExecuteAsync(null);
11097
}
11198

112-
private async void Item_RightTapped(object sender, RightTappedRoutedEventArgs e)
99+
private async void AdaptiveGridView_RightTapped(object sender, RightTappedRoutedEventArgs e)
113100
{
114-
App.Logger.LogWarning("rightTapped");
115101
var itemContextMenuFlyout = new CommandBarFlyout { Placement = FlyoutPlacementMode.Full };
116102
itemContextMenuFlyout.Opening += (sender, e) => App.LastOpenedFlyout = sender as CommandBarFlyout;
117-
if (sender is not StackPanel tagsItemsStackPanel || tagsItemsStackPanel.DataContext is not FileTagsItemViewModel item)
103+
if (e.OriginalSource is not FrameworkElement element || element.DataContext is not FileTagsItemViewModel item)
118104
return;
119105

120-
App.Logger.LogWarning("Item path: " + item.Path + " widgetcarditem.path = " + (item as WidgetCardItem)?.Path);
121106
var menuItems = GetItemMenuItems(item, QuickAccessService.IsItemPinned(item.Path), item.IsFolder);
122107
var (_, secondaryElements) = ItemModelListToContextFlyoutHelper.GetAppBarItemsFromModel(menuItems);
123108

@@ -127,7 +112,7 @@ private async void Item_RightTapped(object sender, RightTappedRoutedEventArgs e)
127112

128113
secondaryElements.ForEach(i => itemContextMenuFlyout.SecondaryCommands.Add(i));
129114
ItemContextMenuFlyout = itemContextMenuFlyout;
130-
itemContextMenuFlyout.ShowAt(tagsItemsStackPanel, new FlyoutShowOptions { Position = e.GetPosition(tagsItemsStackPanel) });
115+
itemContextMenuFlyout.ShowAt(element, new FlyoutShowOptions { Position = e.GetPosition(element) });
131116

132117
await ShellContextmenuHelper.LoadShellMenuItems(item.Path, itemContextMenuFlyout, showOpenWithMenu: true, showSendToMenu: true);
133118
e.Handled = true;

0 commit comments

Comments
 (0)