From 392a613094bc41a4682c239a2feb32d64dc20916 Mon Sep 17 00:00:00 2001 From: Maxime Adler Date: Tue, 15 Apr 2025 14:04:43 +0200 Subject: [PATCH] Fix input text --- .../Shared/Components/Search/SearchInput.razor | 2 ++ .../Components/Search/SearchInput.razor.cs | 11 +++++++++-- .../Shared/Components/Select/Select.razor.cs | 18 ++++++++++++------ .../Components/SelectSearch/SelectSearch.razor | 4 ++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor index 91c332f..db11012 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor @@ -6,6 +6,8 @@ type="text" class="search-field" placeholder="@Placeholder" + disabled="@IsDisable" + style="@(IsDisable ? "pointer-events: none" : "")" @bind=@Text @bind:event="oninput" @bind:after=HandleTextChanged diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs index 2d151d5..5e5f3d1 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Search/SearchInput.razor.cs @@ -8,6 +8,7 @@ public partial class SearchInput { [Parameter] public string? Text { get; set; } [Parameter] public string? Placeholder { get; set; } + [Parameter] public bool IsDisable { get; set; } [Parameter] public EventCallback TextChanged { get; set; } [Parameter] public EventCallback ClearClicked { get; set; } [Parameter] public EventCallback SearchClicked { get; set; } @@ -39,11 +40,17 @@ public partial class SearchInput } private async Task HandleSearchClicked() { - await SearchClicked.InvokeAsync(); + if (!IsDisable) + { + await SearchClicked.InvokeAsync(); + } } private async Task HandleFocusIn() { - await FocusIn.InvokeAsync(); + if (!IsDisable) + { + await FocusIn.InvokeAsync(); + } } private MarkupString GetSearchIcon() diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs index d243500..a494c97 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/Select/Select.razor.cs @@ -24,11 +24,15 @@ public partial class Select private string AddLabel = string.Empty; private EditContext? QuickAddEditContext; - public void Close() => + public void Close() + { IsContentOpen = false; + } - public void Open() => + public void Open() + { IsContentOpen = true; + } protected override void OnInitialized() { @@ -47,12 +51,14 @@ public partial class Select private void HandleButtonClicked() { - if (!DisableClicked) - IsContentOpen = !IsContentOpen; + if (!DisableClicked && IsContentOpen) + Close(); + + if (!DisableClicked && !IsContentOpen) + Open(); } - private void HandleContentClosed() => - IsContentOpen = false; + private void HandleContentClosed() => Close(); private async Task HandleValueClicked(TItem value) { diff --git a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor index a9e74bb..35c1a8a 100644 --- a/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor +++ b/src/GameIdeas/Client/GameIdeas.BlazorApp/Shared/Components/SelectSearch/SelectSearch.razor @@ -5,12 +5,12 @@ @typeparam TItem -