diff --git a/src/MultiShop/Client/Pages/Search.razor b/src/MultiShop/Client/Pages/Search.razor index fdd68b6..01236a7 100644 --- a/src/MultiShop/Client/Pages/Search.razor +++ b/src/MultiShop/Client/Pages/Search.razor @@ -5,7 +5,7 @@
- + diff --git a/src/MultiShop/Client/Pages/Search.razor.cs b/src/MultiShop/Client/Pages/Search.razor.cs index 9650743..e802ad2 100644 --- a/src/MultiShop/Client/Pages/Search.razor.cs +++ b/src/MultiShop/Client/Pages/Search.razor.cs @@ -82,20 +82,16 @@ namespace MultiShop.Client.Pages if (activeSearchProfile == null) activeSearchProfile = new SearchProfile(); if (activeResultsProfile == null) activeResultsProfile = new ResultsProfile(); activeSearchProfile.ShopStates.TotalShops = Shops.Count; - - if (Query != null) - { - searchBar.Query = Query; - await searchBar.Search(); - } } - protected override async Task OnAfterRenderAsync(bool firstRender) + protected override async Task OnParametersSetAsync() { - await base.OnAfterRenderAsync(firstRender); - if (firstRender) - { + await base.OnParametersSetAsync(); + if (Query != null) { searchBar.Query = Query; + await searchBar.Search(); + } else { + searchBar.Ready(); } } diff --git a/src/MultiShop/Client/Shared/SearchBar.razor b/src/MultiShop/Client/Shared/SearchBar.razor index 32d2464..aa3ebf0 100644 --- a/src/MultiShop/Client/Shared/SearchBar.razor +++ b/src/MultiShop/Client/Shared/SearchBar.razor @@ -25,14 +25,28 @@ [Parameter] public EventCallback OnSearchRequested { get; set; } + [Parameter] + public bool StartDisabled { get; set; } + public bool Disabled { get; private set; } private string groupClassCss => "input-group " + (AdditionalAttributes != null && AdditionalAttributes.ContainsKey("class") ? AdditionalAttributes["class"] as string : null); + protected override void OnParametersSet() + { + base.OnParametersSet(); + if (StartDisabled) Disabled = true; + } + public async Task Search() { Disabled = true; await OnSearchRequested.InvokeAsync(Query); Disabled = false; } + + public void Ready() + { + Disabled = false; + } } \ No newline at end of file