Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MudSelectExtended : Searching in Searchbox throws error #482

Open
EGInsider opened this issue Nov 11, 2024 · 6 comments
Open

MudSelectExtended : Searching in Searchbox throws error #482

EGInsider opened this issue Nov 11, 2024 · 6 comments

Comments

@EGInsider
Copy link

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 EGInsider changed the title MudSelectExtended : Searching in Searchbox gives error MudSelectExtended : Searching in Searchbox throws error Nov 11, 2024
@EGInsider
Copy link
Author

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
Copy link
Author

Screenshot 2024-11-12 at 1 04 04 PM

@EGInsider
Copy link
Author

.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
Copy link

Greenspart commented Nov 13, 2024

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
Copy link
Author

EGInsider commented Nov 14, 2024

@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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants