diff --git a/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj b/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj index 3d685ebe4..14a0270e3 100644 --- a/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj +++ b/ErsatzTV.Infrastructure/ErsatzTV.Infrastructure.csproj @@ -16,7 +16,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/ErsatzTV/ErsatzTV.csproj b/ErsatzTV/ErsatzTV.csproj index 06441113d..410a98770 100644 --- a/ErsatzTV/ErsatzTV.csproj +++ b/ErsatzTV/ErsatzTV.csproj @@ -11,8 +11,8 @@ - - + + @@ -20,14 +20,14 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - + + diff --git a/ErsatzTV/Shared/MainLayout.razor b/ErsatzTV/Shared/MainLayout.razor index df20a70b1..30da4ad7b 100644 --- a/ErsatzTV/Shared/MainLayout.razor +++ b/ErsatzTV/Shared/MainLayout.razor @@ -1,4 +1,6 @@ @using System.Reflection +@using Microsoft.AspNetCore.WebUtilities +@using Microsoft.Extensions.Primitives @using System.Web @inherits LayoutComponentBase @inject NavigationManager NavigationManager @@ -15,7 +17,7 @@ ()?.InformationalVersion ?? "unknown"; - private MudTextField _textField; + private string _query; private MudTheme _ersatzTvTheme => new() { @@ -89,12 +91,26 @@ } }; + protected override async Task OnParametersSetAsync() + { + await base.OnParametersSetAsync(); + + string query = new Uri(NavigationManager.Uri).Query; + if (QueryHelpers.ParseQuery(query).TryGetValue("query", out StringValues value)) + { + _query = value; + } + else + { + _query = string.Empty; + } + } + private void OnSearchKeyDown(KeyboardEventArgs args) { if (args.Code == "Enter") { - string query = HttpUtility.UrlEncode(_textField.Value); - _textField.Reset(); + string query = HttpUtility.UrlEncode(_query); NavigationManager.NavigateTo($"/search?query={query}", true); StateHasChanged(); }