From b83741b29d1e921fd7256911ee3afd522e252df7 Mon Sep 17 00:00:00 2001 From: mckaragoz <78308169+mckaragoz@users.noreply.github.com> Date: Thu, 1 May 2025 10:45:34 +0300 Subject: [PATCH] ComboBox Fix Chip Can't Close --- .../Components/ComboboxTests.cs | 14 +++++++------- .../Components/ComboBox/MudComboBox.razor | 16 +--------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/CodeBeam.MudBlazor.Extensions.UnitTests/Components/ComboboxTests.cs b/CodeBeam.MudBlazor.Extensions.UnitTests/Components/ComboboxTests.cs index d0b119b4..5b53f14b 100644 --- a/CodeBeam.MudBlazor.Extensions.UnitTests/Components/ComboboxTests.cs +++ b/CodeBeam.MudBlazor.Extensions.UnitTests/Components/ComboboxTests.cs @@ -171,7 +171,7 @@ public async Task ComboBoxTest1() combobox.Instance.Value.Should().BeNullOrEmpty(); comp.WaitForAssertion(() => comp.Find("div.mud-popover").ClassList.Should().Contain("d-none")); // click and check if it has toggled the menu - input.MouseDown(); + input.Click(); menu.ClassList.Should().NotContain("d-none"); // now click an item and see the value change comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item").Count.Should().BeGreaterThan(0)); @@ -182,7 +182,7 @@ public async Task ComboBoxTest1() combobox.Instance.Value.Should().Be("2"); // now we cheat and click the list without opening the menu ;) - input.MouseDown(); + input.Click(); comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item").Count.Should().BeGreaterThan(0)); items = comp.FindAll("div.mud-combobox-item").ToArray(); @@ -205,7 +205,7 @@ public async Task ComboBoxClearableTest() // No button when initialized comp.FindAll("button").Should().BeEmpty(); - input.MouseDown(); + input.Click(); comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item").Count.Should().BeGreaterThan(0)); // Button shows after selecting item var items = comp.FindAll("div.mud-combobox-item").ToArray(); @@ -230,7 +230,7 @@ public void MultiSelect_SelectAll() var menu = comp.Find("div.mud-popover"); var input = combobox.Find("div.mud-input-control"); // Open the menu - input.MouseDown(); + input.Click(); comp.WaitForAssertion(() => menu.ClassList.Should().Contain("mud-popover-open")); comp.FindAll("div.mud-combobox-item")[0].Click(); @@ -259,7 +259,7 @@ public async Task ComboBox_MultiSelectEditable() comp.WaitForAssertion(() => comp.Find("div.mud-popover").ClassList.Should().Contain("d-none")); // click and check if it has toggled the menu - await comp.InvokeAsync(() => input.MouseDown()); + await comp.InvokeAsync(() => input.Click()); comp.WaitForAssertion(() => comp.Find("div.mud-popover").ClassList.Should().NotContain("d-none")); // now click an item and see the value change comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item").Count.Should().Be(4)); @@ -289,7 +289,7 @@ public async Task ComboBox_MultiSelectTest1() comp.WaitForAssertion(() => comp.Find("div.mud-popover").ClassList.Should().Contain("d-none")); // click and check if it has toggled the menu - await comp.InvokeAsync(() => input.MouseDown()); + await comp.InvokeAsync(() => input.Click()); comp.WaitForAssertion(() => comp.Find("div.mud-popover").ClassList.Should().NotContain("d-none")); // now click an item and see the value change comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item").Count.Should().BeGreaterThan(0)); @@ -324,7 +324,7 @@ await comp.InvokeAsync(() => { combobox.Instance.SelectedValues = new HashSet() { "1", "2" }; }); - await comp.InvokeAsync(() => input.MouseDown()); + await comp.InvokeAsync(() => input.Click()); comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item path")[1]?.Attributes["d"]?.Value.Should().Be(@checked)); comp.FindAll("div.mud-combobox-item path")[3]?.Attributes["d"]?.Value.Should().Be(@checked); combobox.Instance.SelectedValues.Should().NotContain("3"); diff --git a/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor b/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor index f7d386b8..8d98bf01 100644 --- a/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor +++ b/CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor @@ -11,7 +11,7 @@
+ Error="@Error" ErrorText="@ErrorText" ErrorId="@ErrorId" Disabled="@Disabled" @onclick="@ToggleMenu" Required="@Required" ForId="@FieldId"> @*DataVisualiserStyle="@($"min-height: 1.1876em;{(HasValue(Value) && Editable == true ? "padding-bottom: 0px" : null)}")"*@ SelectedValues.Contains(x))) - { - - } - } - else - { - foreach (var item in Items.Where(x => (MultiSelection ? SelectedValues.Contains(x.Value) : Value?.Equals(x.Value) == true)) ?? new List>()) - { - - } - }*@ } else if (InputPresenter == ValuePresenter.Text && (!Editable || (MultiSelection && Editable)))