diff --git a/FasdDesktopUi/Basics/UserControls/HierarchicalSelectionControl.xaml b/FasdDesktopUi/Basics/UserControls/HierarchicalSelectionControl.xaml index a1318b9..47ee688 100644 --- a/FasdDesktopUi/Basics/UserControls/HierarchicalSelectionControl.xaml +++ b/FasdDesktopUi/Basics/UserControls/HierarchicalSelectionControl.xaml @@ -30,14 +30,14 @@ BorderThickness="{TemplateBinding BorderThickness}" Style="{StaticResource ComboBoxToggleButton}" /> - + itemLookup = new Dictionary(); private readonly DispatcherTimer searchDelayTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(250) }; private string lastSearchText = string.Empty; + private bool suppressTreeSelectionChanged; private TextBox searchTextBox; private TreeView treeViewControl; @@ -82,6 +83,7 @@ namespace FasdDesktopUi.Basics.UserControls { if (d is HierarchicalSelectionControl control) { + control.LogSelectedItemChange(e.NewValue as HierarchicalSelectionItem); control.TryExpandToSelectedItem(); } } @@ -111,6 +113,7 @@ namespace FasdDesktopUi.Basics.UserControls EnsureTemplateParts(); searchTextBox?.Focus(); searchTextBox?.SelectAll(); + suppressTreeSelectionChanged = false; LogEntry($"[CategoryPicker] DropDownOpened. Selected={SelectedItem?.FullPath ?? ""}"); DropDownOpened?.Invoke(this, e); } @@ -118,6 +121,7 @@ namespace FasdDesktopUi.Basics.UserControls private void ComboBoxControl_DropDownClosed(object sender, EventArgs e) { searchDelayTimer.Stop(); + suppressTreeSelectionChanged = false; LogEntry("[CategoryPicker] DropDownClosed"); DropDownClosed?.Invoke(this, e); } @@ -138,6 +142,9 @@ namespace FasdDesktopUi.Basics.UserControls private void TreeViewControl_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) { + if (suppressTreeSelectionChanged) + return; + if (e.NewValue is HierarchicalSelectionItem selected) { var original = ResolveOriginalItem(selected); @@ -147,6 +154,7 @@ namespace FasdDesktopUi.Basics.UserControls LogEntry($"[CategoryPicker] Tree selection changed: {original.FullPath}"); } + suppressTreeSelectionChanged = true; ComboBoxControl.IsDropDownOpen = false; } } @@ -251,7 +259,20 @@ namespace FasdDesktopUi.Basics.UserControls private void UpdateDisplaySelection() { - // Display handled by ComboBox DisplayMemberPath (FullPath). + // Display handled by template TextBlock bound to SelectedItem.FullPath. + } + + private void LogSelectedItemChange(HierarchicalSelectionItem newValue) + { + var description = ""; + if (newValue != null) + { + var fullPath = string.IsNullOrWhiteSpace(newValue.FullPath) ? newValue.DisplayName : newValue.FullPath; + var id = string.IsNullOrWhiteSpace(newValue.Id) ? "" : newValue.Id; + description = $"{fullPath} (Id={id})"; + } + + LogEntry($"[CategoryPicker] DependencyProperty SelectedItem updated -> {description}"); } protected override void OnPreviewKeyDown(KeyEventArgs e) diff --git a/FasdDesktopUi/Basics/UserControls/Ticket/CloseCaseDialogWithTicket.xaml.cs b/FasdDesktopUi/Basics/UserControls/Ticket/CloseCaseDialogWithTicket.xaml.cs index a6de957..68bd5ec 100644 --- a/FasdDesktopUi/Basics/UserControls/Ticket/CloseCaseDialogWithTicket.xaml.cs +++ b/FasdDesktopUi/Basics/UserControls/Ticket/CloseCaseDialogWithTicket.xaml.cs @@ -229,10 +229,27 @@ namespace FasdDesktopUi.Basics.UserControls private static void OnSelectedCategoryChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { - // Reserved for future use when additional reactions are required. + if (d is CloseCaseDialogWithTicket instance) + instance.LogSelectedCategoryChanged(e.NewValue as HierarchicalSelectionItem); } - #endregion + #endregion + + private void LogSelectedCategoryChanged(HierarchicalSelectionItem category) + { + try + { + var fullPath = category == null + ? "" + : string.IsNullOrWhiteSpace(category.FullPath) ? category.DisplayName : category.FullPath; + var id = category == null || string.IsNullOrWhiteSpace(category.Id) ? "" : category.Id; + LogEntry($"[CloseCaseDialog] SelectedCategory updated -> {fullPath} (Id={id})"); + } + catch (Exception ex) + { + LogException(ex); + } + } public bool ShowServiceHasBeenChangedWarning {