Skip to content

Fix: Fixed issue where checkboxes might remain visible #12104

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
Apr 17, 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
22 changes: 11 additions & 11 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -553,16 +553,6 @@
Width="24"
HorizontalAlignment="Left"
VerticalAlignment="Stretch">
<CheckBox
x:Name="SelectionCheckbox"
Width="20"
MinWidth="0"
HorizontalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
Checked="ItemSelected_Checked"
DoubleTapped="SelectionCheckbox_DoubleTapped"
Unchecked="ItemSelected_Unchecked"
Visibility="Collapsed" />
<Grid
x:Name="IconBox"
Width="20"
Expand Down Expand Up @@ -634,6 +624,16 @@
Source="{x:Bind ShieldIcon, Mode=OneWay}"
Stretch="Uniform" />
</Grid>
<CheckBox
x:Name="SelectionCheckbox"
Width="20"
MinWidth="0"
HorizontalAlignment="Center"
AutomationProperties.AccessibilityView="Raw"
Checked="ItemSelected_Checked"
DoubleTapped="SelectionCheckbox_DoubleTapped"
Opacity="0"
Unchecked="ItemSelected_Unchecked" />
</Grid>

<Grid
Expand Down Expand Up @@ -806,7 +806,7 @@
<VisualState x:Name="HideCheckbox" />
<VisualState x:Name="ShowCheckbox">
<VisualState.Setters>
<Setter Target="SelectionCheckbox.Visibility" Value="Visible" />
<Setter Target="SelectionCheckbox.Opacity" Value="1" />
<Setter Target="IconBox.Visibility" Value="Collapsed" />
</VisualState.Setters>
</VisualState>
Expand Down
25 changes: 5 additions & 20 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -708,21 +708,16 @@ private void ItemSelected_Unchecked(object sender, RoutedEventArgs e)

private new void FileList_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
{
var iconBox = args.ItemContainer.FindDescendant("IconBox")!;
var selectionCheckbox = args.ItemContainer.FindDescendant("SelectionCheckbox")!;

iconBox.PointerEntered -= IconBox_PointerEntered;
iconBox.PointerExited -= IconBox_PointerExited;
iconBox.PointerCanceled -= IconBox_PointerCanceled;
selectionCheckbox.PointerEntered -= SelectionCheckbox_PointerEntered;
selectionCheckbox.PointerExited -= SelectionCheckbox_PointerExited;
selectionCheckbox.PointerCanceled -= SelectionCheckbox_PointerCanceled;

base.FileList_ContainerContentChanging(sender, args);
SetCheckboxSelectionState(args.Item, args.ItemContainer as ListViewItem);

iconBox.PointerEntered += IconBox_PointerEntered;
iconBox.PointerExited += IconBox_PointerExited;
iconBox.PointerCanceled += IconBox_PointerCanceled;
selectionCheckbox.PointerEntered += SelectionCheckbox_PointerEntered;
selectionCheckbox.PointerExited += SelectionCheckbox_PointerExited;
selectionCheckbox.PointerCanceled += SelectionCheckbox_PointerCanceled;
}
Expand All @@ -744,7 +739,7 @@ private void SetCheckboxSelectionState(object item, ListViewItem? lviContainer =
checkbox.Checked += ItemSelected_Checked;
checkbox.Unchecked += ItemSelected_Unchecked;
}
UpdateCheckboxVisibility(container, false);
UpdateCheckboxVisibility(container, checkbox?.IsPointerOver ?? false);
}
}

Expand Down Expand Up @@ -784,21 +779,11 @@ private void TagIcon_Tapped(object sender, TappedRoutedEventArgs e)
e.Handled = true;
}

private void IconBox_PointerEntered(object sender, PointerRoutedEventArgs e)
private void SelectionCheckbox_PointerEntered(object sender, PointerRoutedEventArgs e)
{
UpdateCheckboxVisibility((sender as FrameworkElement)!.FindAscendant<ListViewItem>()!, true);
}

private void IconBox_PointerExited(object sender, PointerRoutedEventArgs e)
{
e.Handled = true;
}

private void IconBox_PointerCanceled(object sender, PointerRoutedEventArgs e)
{
e.Handled = true;
}

private void SelectionCheckbox_PointerExited(object sender, PointerRoutedEventArgs e)
{
UpdateCheckboxVisibility((sender as FrameworkElement)!.FindAscendant<ListViewItem>()!, false);
Expand All @@ -817,7 +802,7 @@ private void UpdateCheckboxVisibility(object sender, bool isPointerOver)
// Show checkboxes when items are selected (as long as the setting is enabled)
// Show checkboxes when hovering of the thumbnail (regardless of the setting to hide them)
if (UserSettingsService.FoldersSettingsService.ShowCheckboxesWhenSelectingItems && control.IsSelected
|| isPointerOver || (control.FindDescendant("SelectionCheckbox") as CheckBox)!.IsPointerOver)
|| isPointerOver)
VisualStateManager.GoToState(userControl, "ShowCheckbox", true);
else
VisualStateManager.GoToState(userControl, "HideCheckbox", true);
Expand Down