From 518f216f7729afc35f3358d7559d392a5bc6e006 Mon Sep 17 00:00:00 2001 From: Corvin <43533385+corvinsz@users.noreply.github.com> Date: Tue, 8 Sep 2026 16:21:27 +0200 Subject: [PATCH] fix(combobox): allow dropdown toggle when clicking prefix or suffix text --- .../Themes/MaterialDesignTheme.ComboBox.xaml | 2 ++ .../WPF/ComboBoxes/ComboBoxTests.cs | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml index 5746b3ddd4..72a49c8da4 100644 --- a/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml +++ b/src/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.ComboBox.xaml @@ -350,6 +350,7 @@ Grid.Column="1" Margin="0,0,2,0" FontSize="{TemplateBinding FontSize}" + IsHitTestVisible="False" Opacity="{TemplateBinding wpf:HintAssist.HintOpacity}" Text="{TemplateBinding wpf:TextFieldAssist.PrefixText}" VerticalAlignment="Center"> @@ -446,6 +447,7 @@ Grid.Column="3" Margin="2,0,0,0" FontSize="{TemplateBinding FontSize}" + IsHitTestVisible="False" Opacity="{TemplateBinding wpf:HintAssist.HintOpacity}" Text="{TemplateBinding wpf:TextFieldAssist.SuffixText}" VerticalAlignment="Center"> diff --git a/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs b/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs index c784351d2e..6dec4654c4 100644 --- a/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs +++ b/tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs @@ -299,4 +299,39 @@ public async Task ComboBox_UsesDropDownBackgroundResource_WhenBackgroundIsNotSet await Assert.That(popupBackground).IsNotNull(); await Assert.That(popupBackground).IsEqualTo((Color)ColorConverter.ConvertFromString("#CC336699")); } + + [Test] + [Description("https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/issues/4090")] + public async Task ComboBox_OpensDropDown_WhenClickingOnPrefixOrSuffixTextBlock() + { + var comboBox = await LoadXaml($""" + + + + + + + """); + + await Assert.That(await comboBox.GetIsDropDownOpen()).IsFalse(); + + var prefixTextBlock = await comboBox.GetElement("PrefixTextBlock"); + await AssertOpensAndClosesDropDown(prefixTextBlock); + + var suffixTextBlock = await comboBox.GetElement("SuffixTextBlock"); + await AssertOpensAndClosesDropDown(suffixTextBlock); + + async Task AssertOpensAndClosesDropDown(IVisualElement textBlock) + { + await textBlock.LeftClick(); + await Task.Delay(50, TestContext.Current!.Execution.CancellationToken); + await Assert.That(await comboBox.GetIsDropDownOpen()).IsTrue(); + + await textBlock.LeftClick(); + await Task.Delay(50, TestContext.Current!.Execution.CancellationToken); + await Assert.That(await comboBox.GetIsDropDownOpen()).IsFalse(); + } + } }