Skip to content

Commit 102fcd0

Browse files
authored
ComboBox Fix Chip Can't Close (#523)
1 parent 87197cc commit 102fcd0

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

CodeBeam.MudBlazor.Extensions.UnitTests/Components/ComboboxTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public async Task ComboBoxTest1()
171171
combobox.Instance.Value.Should().BeNullOrEmpty();
172172
comp.WaitForAssertion(() => comp.Find("div.mud-popover").ClassList.Should().Contain("d-none"));
173173
// click and check if it has toggled the menu
174-
input.MouseDown();
174+
input.Click();
175175
menu.ClassList.Should().NotContain("d-none");
176176
// now click an item and see the value change
177177
comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item").Count.Should().BeGreaterThan(0));
@@ -182,7 +182,7 @@ public async Task ComboBoxTest1()
182182
combobox.Instance.Value.Should().Be("2");
183183
// now we cheat and click the list without opening the menu ;)
184184

185-
input.MouseDown();
185+
input.Click();
186186
comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item").Count.Should().BeGreaterThan(0));
187187
items = comp.FindAll("div.mud-combobox-item").ToArray();
188188

@@ -205,7 +205,7 @@ public async Task ComboBoxClearableTest()
205205
// No button when initialized
206206
comp.FindAll("button").Should().BeEmpty();
207207

208-
input.MouseDown();
208+
input.Click();
209209
comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item").Count.Should().BeGreaterThan(0));
210210
// Button shows after selecting item
211211
var items = comp.FindAll("div.mud-combobox-item").ToArray();
@@ -230,7 +230,7 @@ public void MultiSelect_SelectAll()
230230
var menu = comp.Find("div.mud-popover");
231231
var input = combobox.Find("div.mud-input-control");
232232
// Open the menu
233-
input.MouseDown();
233+
input.Click();
234234
comp.WaitForAssertion(() => menu.ClassList.Should().Contain("mud-popover-open"));
235235

236236
comp.FindAll("div.mud-combobox-item")[0].Click();
@@ -259,7 +259,7 @@ public async Task ComboBox_MultiSelectEditable()
259259
comp.WaitForAssertion(() =>
260260
comp.Find("div.mud-popover").ClassList.Should().Contain("d-none"));
261261
// click and check if it has toggled the menu
262-
await comp.InvokeAsync(() => input.MouseDown());
262+
await comp.InvokeAsync(() => input.Click());
263263
comp.WaitForAssertion(() => comp.Find("div.mud-popover").ClassList.Should().NotContain("d-none"));
264264
// now click an item and see the value change
265265
comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item").Count.Should().Be(4));
@@ -289,7 +289,7 @@ public async Task ComboBox_MultiSelectTest1()
289289
comp.WaitForAssertion(() =>
290290
comp.Find("div.mud-popover").ClassList.Should().Contain("d-none"));
291291
// click and check if it has toggled the menu
292-
await comp.InvokeAsync(() => input.MouseDown());
292+
await comp.InvokeAsync(() => input.Click());
293293
comp.WaitForAssertion(() => comp.Find("div.mud-popover").ClassList.Should().NotContain("d-none"));
294294
// now click an item and see the value change
295295
comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item").Count.Should().BeGreaterThan(0));
@@ -324,7 +324,7 @@ await comp.InvokeAsync(() =>
324324
{
325325
combobox.Instance.SelectedValues = new HashSet<string>() { "1", "2" };
326326
});
327-
await comp.InvokeAsync(() => input.MouseDown());
327+
await comp.InvokeAsync(() => input.Click());
328328
comp.WaitForAssertion(() => comp.FindAll("div.mud-combobox-item path")[1]?.Attributes["d"]?.Value.Should().Be(@checked));
329329
comp.FindAll("div.mud-combobox-item path")[3]?.Attributes["d"]?.Value.Should().Be(@checked);
330330
combobox.Instance.SelectedValues.Should().NotContain("3");

CodeBeam.MudBlazor.Extensions/Components/ComboBox/MudComboBox.razor

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<CascadingValue Value="@this" IsFixed="true">
1212
<div class="mud-select-extended" id="@_elementId">
1313
<MudInputControl Label="@Label" Variant="@Variant" HelperText="@HelperText" HelperTextOnFocus="@HelperTextOnFocus" FullWidth="@FullWidth" Margin="@Margin" Class="@Classname" Style="@Style"
14-
Error="@Error" ErrorText="@ErrorText" ErrorId="@ErrorId" Disabled="@Disabled" @onmousedown="@ToggleMenu" Required="@Required" ForId="@FieldId">
14+
Error="@Error" ErrorText="@ErrorText" ErrorId="@ErrorId" Disabled="@Disabled" @onclick="@ToggleMenu" Required="@Required" ForId="@FieldId">
1515
<InputContent>
1616
@*DataVisualiserStyle="@($"min-height: 1.1876em;{(HasValue(Value) && Editable == true ? "padding-bottom: 0px" : null)}")"*@
1717
<MudInputExtended @ref="_inputReference" T="string" InputType="@(Editable && !MultiSelection ? InputType.Text : InputType.Hidden)"
@@ -49,20 +49,6 @@
4949
}
5050
}
5151
}
52-
@*@if (ItemCollection is not null)
53-
{
54-
foreach (var item in ItemCollection.Where(x => SelectedValues.Contains(x)))
55-
{
56-
<MudChip Class="@ChipClass" Value="@item" Text="@Converter.Set(item)" Color="@Color" Size="@ChipSize" Variant="@ChipVariant" @onmousedown:stopPropagation />
57-
}
58-
}
59-
else
60-
{
61-
foreach (var item in Items.Where(x => (MultiSelection ? SelectedValues.Contains(x.Value) : Value?.Equals(x.Value) == true)) ?? new List<MudComboBoxItem<T>>())
62-
{
63-
<MudChip Class="@ChipClass" Value="item.Value" Text="@(ToStringFunc is not null ? ToStringFunc.Invoke(item.Value) : string.IsNullOrWhiteSpace(item.Text) ? Converter.Set(item.Value) : item.Text)" Color="@Color" Size="@ChipSize" Variant="@ChipVariant" @onmousedown:stopPropagation />
64-
}
65-
}*@
6652
</MudChipSet>
6753
}
6854
else if (InputPresenter == ValuePresenter.Text && (!Editable || (MultiSelection && Editable)))

0 commit comments

Comments
 (0)