From 35db764d8d0073ec56e4d0a73b999c6a88e3b27c Mon Sep 17 00:00:00 2001 From: adelacruz Date: Thu, 14 Nov 2024 19:15:18 +0100 Subject: [PATCH] fix: double click commit checkout - When a commit was selected and you double tapped an empty section of the histories ListBox, the last selected commit was checkout. - Using the 'TappedEventArgs' properties, and validating the name of the tapped section (PART_ContentPresenter) we can avoid this. --- src/Views/Histories.axaml.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Views/Histories.axaml.cs b/src/Views/Histories.axaml.cs index 85092b64..caaa17c9 100644 --- a/src/Views/Histories.axaml.cs +++ b/src/Views/Histories.axaml.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; +using System.Reflection; using Avalonia; using Avalonia.Collections; @@ -730,7 +731,16 @@ namespace SourceGit.Views private void OnCommitListDoubleTapped(object sender, TappedEventArgs e) { - if (DataContext is ViewModels.Histories histories && sender is ListBox { SelectedItems: { Count: 1 } selected }) + // Retrieve the PropertyInfo for the "Name" property + var nameProperty = e.Source.GetType().GetProperty("Name"); + + // Get the value of the "Name" property, or null if it doesn't exist + string nameValue = nameProperty?.GetValue(e.Source) as string; + + // Check if has clicked the Background of the ListBox + bool isInvalidUiPressed = nameValue == "PART_ContentPresenter"; + + if (DataContext is ViewModels.Histories histories && !isInvalidUiPressed && sender is ListBox { SelectedItems: { Count: 1 } selected }) { histories.DoubleTapped(selected[0] as Models.Commit); }