Skip to content

Commit 56dfe63

Browse files
authored
[Autocomplete] Fix ReadOnly and Disable properties (#2291)
1 parent 53f826d commit 56dfe63

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/Core/Components/List/FluentAutocomplete.razor

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
aria-label="@GetAutocompleteAriaLabel()"
2727
Value="@ValueText"
2828
@onclick="@OnDropDownExpandedAsync"
29-
@oninput="@InputHandlerAsync"
29+
@oninput="@InputHandlerAsync"
3030
autofocus="@Autofocus"
3131
Style="@ComponentWidth">
3232
@* Selected Items *@
@@ -68,7 +68,7 @@
6868
}
6969

7070
}
71-
@if (!Disabled)
71+
@if (!Disabled && !ReadOnly)
7272
{
7373
if (this.SelectedOptions?.Any() == true || !string.IsNullOrEmpty(ValueText))
7474
{
@@ -205,12 +205,22 @@
205205
{
206206
var text = @GetOptionText(item);
207207

208-
<FluentBadge Appearance="@AspNetCore.Components.Appearance.Neutral"
209-
OnDismissClick="@(e => RemoveSelectedItemAsync(item))"
210-
DismissTitle="@(string.Format(AccessibilityRemoveItem, text))"
211-
aria-label="@GetOptionText(item)">
212-
@text
213-
</FluentBadge>
208+
if (ReadOnly || Disabled)
209+
{
210+
<FluentBadge Appearance="@AspNetCore.Components.Appearance.Neutral"
211+
aria-label="@GetOptionText(item)">
212+
@text
213+
</FluentBadge>
214+
}
215+
else
216+
{
217+
<FluentBadge Appearance="@AspNetCore.Components.Appearance.Neutral"
218+
OnDismissClick="@(e => RemoveSelectedItemAsync(item))"
219+
DismissTitle="@(string.Format(AccessibilityRemoveItem, text))"
220+
aria-label="@GetOptionText(item)">
221+
@text
222+
</FluentBadge>
223+
}
214224
}
215225
else
216226
{

src/Core/Components/List/FluentAutocomplete.razor.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ private string ComponentWidth
265265
/// <summary />
266266
protected override async Task InputHandlerAsync(ChangeEventArgs e)
267267
{
268+
if (ReadOnly || Disabled)
269+
{
270+
return;
271+
}
272+
268273
ValueText = e.Value?.ToString() ?? string.Empty;
269274
await RaiseValueTextChangedAsync(ValueText);
270275

0 commit comments

Comments
 (0)