From 040ec30d8a44cb96dbe5b5f62301300094589045 Mon Sep 17 00:00:00 2001 From: Denis Voituron Date: Fri, 28 Jun 2024 12:49:51 +0200 Subject: [PATCH] [Autocomplete] Fix ReadOnly and Disable properties (#2291) --- .../Components/List/FluentAutocomplete.razor | 35 +++++++++++++------ .../List/FluentAutocomplete.razor.cs | 5 +++ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/Core/Components/List/FluentAutocomplete.razor b/src/Core/Components/List/FluentAutocomplete.razor index b86a7e79fb..8203d20c48 100644 --- a/src/Core/Components/List/FluentAutocomplete.razor +++ b/src/Core/Components/List/FluentAutocomplete.razor @@ -6,24 +6,27 @@
- @* Selected Items *@ @@ -65,7 +68,7 @@ } } - @if (!Disabled) + @if (!Disabled && !ReadOnly) { if (this.SelectedOptions?.Any() == true || !string.IsNullOrEmpty(ValueText)) { @@ -76,6 +79,7 @@ Style="cursor: pointer;" Slot="end" Title="Clear" + @onfocus="@(e => { IsReachedMaxItems = false; IsMultiSelectOpened = false; })" tabindex="0" role="button" OnClick="@OnClearAsync" /> @@ -90,6 +94,7 @@ Style="cursor: pointer;" Slot="end" Title="Search" + @onfocus="@(e => { IsReachedMaxItems = false; IsMultiSelectOpened = false; })" tabindex="0" role="button" OnClick="@OnDropDownExpandedAsync" /> @@ -200,12 +205,22 @@ { var text = @GetOptionText(item); - - @text - + if (ReadOnly || Disabled) + { + + @text + + } + else + { + + @text + + } } else { diff --git a/src/Core/Components/List/FluentAutocomplete.razor.cs b/src/Core/Components/List/FluentAutocomplete.razor.cs index c6413da381..2a2a3deb10 100644 --- a/src/Core/Components/List/FluentAutocomplete.razor.cs +++ b/src/Core/Components/List/FluentAutocomplete.razor.cs @@ -270,6 +270,11 @@ private string ComponentWidth /// protected async Task InputHandlerAsync(ChangeEventArgs e) { + if (ReadOnly || Disabled) + { + return; + } + ValueText = e.Value?.ToString() ?? string.Empty; await ValueTextChanged.InvokeAsync(ValueText);