CodeBeamOrg / CodeBeam.MudBlazor.Extensions

Useful third party extension components for MudBlazor, from the contributors.
https://mudextensions.codebeam.org/
MIT License
440 stars 69 forks source link

MudSelectExtended : Searching in Searchbox throws error #482

Open EGInsider opened 2 weeks ago

EGInsider commented 2 weeks ago

SAMPLE CODE

<MudSelectExtended MultiSelection="true" ItemCollection="_states" SearchBox="true" SearchBoxAutoFocus="@false" SearchFunc="@(new Func<string, string, bool>(SearchItems))" T="string" Label="Custom Search Func" AnchorOrigin="Origin.BottomCenter" Variant="Variant.Outlined" SearchBoxPlaceholder="Some Placeholder" SearchBoxClearable="true" />

     private string[] _states =
    {
        "Alabama", "Alaska", "American Samoa", "Arizona",
        "Arkansas", "California", "Colorado", "Connecticut",
        "Delaware", "District of Columbia", "Federated States of Micronesia",
        "Florida", "Georgia", "Guam", "Hawaii", "Idaho",
        "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky",
        "Louisiana", "Maine", "Marshall Islands", "Maryland",
        "Massachusetts", "Michigan", "Minnesota", "Mississippi",
        "Missouri", "Montana", "Nebraska", "Nevada",
        "New Hampshire", "New Jersey", "New Mexico", "New York",
        "North Carolina", "North Dakota", "Northern Mariana Islands", "Ohio",
        "Oklahoma", "Oregon", "Palau", "Pennsylvania", "Puerto Rico",
        "Rhode Island", "South Carolina", "South Dakota", "Tennessee",
        "Texas", "Utah", "Vermont", "Virgin Island", "Virginia",
        "Washington", "West Virginia", "Wisconsin", "Wyoming",
    };

    private bool SearchItems(string value, string searchString)
    {
        if (searchString == "")
        {
            return true;
        }

        if (value.StartsWith(searchString, StringComparison.CurrentCultureIgnoreCase))
        {
            return true;
        }

        return false;
    }

ERROR

Uncaught (in promise) Error: System.Text.Json.JsonException: The JSON value could not be converted to Microsoft.AspNetCore.Components.Web.KeyboardEventArgs. Path: $ | LineNumber: 0 | BytePositionInLine: 15.
   at System.Text.Json.ThrowHelper.ThrowJsonException_DeserializeUnableToConvertValue(Type propertyType)
   at System.Text.Json.Serialization.Converters.ObjectDefaultConverter`1[[Microsoft.AspNetCore.Components.Web.KeyboardEventArgs, Microsoft.AspNetCore.Components.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].OnTryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, KeyboardEventArgs& value)
   at System.Text.Json.Serialization.JsonConverter`1[[Microsoft.AspNetCore.Components.Web.KeyboardEventArgs, Microsoft.AspNetCore.Components.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, KeyboardEventArgs& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1[[Microsoft.AspNetCore.Components.Web.KeyboardEventArgs, Microsoft.AspNetCore.Components.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1[[Microsoft.AspNetCore.Components.Web.KeyboardEventArgs, Microsoft.AspNetCore.Components.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1[[Microsoft.AspNetCore.Components.Web.KeyboardEventArgs, Microsoft.AspNetCore.Components.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].DeserializeAsObject(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadAsObject(Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize(Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
   at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.ParseArguments(JSRuntime jsRuntime, String methodIdentifier, String arguments, Type[] parameterTypes)
   at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.InvokeSynchronously(JSRuntime jsRuntime, DotNetInvocationInfo& callInfo, IDotNetObjectReference objectReference, String argsJson)
   at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.BeginInvokeDotNet(JSRuntime jsRuntime, DotNetInvocationInfo invocationInfo, String argsJson)
    at b.endInvokeDotNetFromJS (blazor.webassembly.js:1:3136)
    at Object.gn [as endInvokeDotNetFromJS] (blazor.webassembly.js:1:58943)
    at invoke-js.ts:233:31
    at Ll (invoke-js.ts:276:5)
    at do_icall (0644bfea:0x70164d)
    at do_icall_wrapper (0644bfea:0x6fc58f)
    at mono_interp_exec_method (0644bfea:0x6ee4a1)
    at interp_runtime_invoke (0644bfea:0x6fdea4)
    at mono_jit_runtime_invoke (0644bfea:0x810ca7)
    at do_runtime_invoke (0644bfea:0x7d15a5)
EGInsider commented 2 weeks ago

i even tried without the custom search function and even then i faced the same error

<MudSelectExtended MultiSelection="true" ItemCollection="_states" SearchBox="true" SearchBoxAutoFocus="false" T="string" Label="Standard Search" AnchorOrigin="Origin.BottomCenter" Variant="Variant.Outlined" HelperText="Search with 'Contains' logic" SearchBoxClearable="true" />
EGInsider commented 2 weeks ago
Screenshot 2024-11-12 at 1 04 04 PM
EGInsider commented 2 weeks ago

.csproj

    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
    <PackageReference Include="MudBlazor" Version="7.15.0" />
    <PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="7.0.2" />
Greenspart commented 2 weeks ago

I have the exact same problem :( searching works fine but I have the same error in my console. Edit: Are you also using InteractiveServerRenderMode ?

EGInsider commented 2 weeks ago

@Greenspart yeah searching works fine but error pops up on console....not sure of InteractiveServerRenderMode setting. Can you give me a reference or sample code?

mckaragoz commented 1 week ago

I can't reproduce it. Could you try with the latest (v 7.1.0)?