Skip to content

Fix: Fixed issue where item names in the Tags widget didn't have ellipsis #12651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/Files.App/UserControls/Widgets/FileTagsWidget.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
IsItemClickEnabled="True"
ItemClick="FileTagItem_ItemClick"
ItemsSource="{x:Bind Tags}"
RightTapped="AdaptiveGridView_RightTapped"
SelectionMode="None"
StretchContentForSingleRow="False">
<controls:AdaptiveGridView.ItemContainerStyle>
Expand All @@ -108,24 +109,30 @@

<controls:AdaptiveGridView.ItemTemplate>
<DataTemplate x:DataType="vm:FileTagsItemViewModel">
<StackPanel
<Grid
ColumnSpacing="8"
DataContext="{x:Bind}"
Orientation="Horizontal"
RightTapped="Item_RightTapped"
Spacing="8">
ToolTipService.ToolTip="{x:Bind Path}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<!-- Icon -->
<Image
Grid.Column="0"
Width="20"
Height="20"
VerticalAlignment="Center"
Source="{x:Bind Icon, Mode=OneWay, Converter={StaticResource ImageModelToImageConverter}}" />

<!-- Name -->
<TextBlock
Grid.Column="1"
VerticalAlignment="Center"
Text="{x:Bind Name, Mode=OneWay}"
TextTrimming="CharacterEllipsis" />
</StackPanel>
</Grid>
</DataTemplate>
</controls:AdaptiveGridView.ItemTemplate>
</controls:AdaptiveGridView>
Expand Down
21 changes: 3 additions & 18 deletions src/Files.App/UserControls/Widgets/FileTagsWidget.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
// Copyright (c) 2023 Files Community
// Licensed under the MIT License. See the LICENSE.

using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using Files.App.Extensions;
using Files.App.Filesystem;
using Files.App.Helpers;
using Files.App.Helpers.ContextFlyouts;
using Files.App.ViewModels;
using Files.App.ViewModels.Widgets;
using Files.Backend.Services.Settings;
using Files.Shared.Extensions;
using Microsoft.Extensions.Logging;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Input;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.Storage;

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

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

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

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

secondaryElements.ForEach(i => itemContextMenuFlyout.SecondaryCommands.Add(i));
ItemContextMenuFlyout = itemContextMenuFlyout;
itemContextMenuFlyout.ShowAt(tagsItemsStackPanel, new FlyoutShowOptions { Position = e.GetPosition(tagsItemsStackPanel) });
itemContextMenuFlyout.ShowAt(element, new FlyoutShowOptions { Position = e.GetPosition(element) });

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