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

[Bug] ArgumentNullException after pressing 'backspace' key #300

Open
oruchreis opened this issue Dec 7, 2022 · 0 comments
Open

[Bug] ArgumentNullException after pressing 'backspace' key #300

oruchreis opened this issue Dec 7, 2022 · 0 comments
Labels
Bug Something isn't working Triage Issue needs to be triaged

Comments

@oruchreis
Copy link

oruchreis commented Dec 7, 2022

Describe the bug
If we type a few letter less than MinimumLength and IsMultiselect is true, we get ArgumentNullException after clearing text by pressing backspace key. This error occurs when the MinimumLength property is set and the search metod is not triggered because of count of letters is not reached MinimumLength yet, and backspace key is used for clearing.

      System.ArgumentNullException: Value cannot be null. (Parameter 'source')
         at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
         at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source)
         at Blazored.Typeahead.BlazoredTypeahead`2.HandleKeyup(KeyboardEventArgs args)
         at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
         at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

To Reproduce

  • Add these to a page
<BlazoredTypeahead TItem="string" TValue="string"
                   AddItemOnEmptyResultMethod="AddNewAsync"
                   SearchMethod="Search" @bind-Values="_values"
                   MinimumLength="3">
    <SelectedTemplate>@context</SelectedTemplate>
    <ResultTemplate>@context</ResultTemplate>
</BlazoredTypeahead>
@code {
    private IList<string>? _values { get; set; }

    private Task<IEnumerable<string>> Search(string? searchText)
    {
        return Task.FromResult(Array.Empty<string>().AsEnumerable());
    }

    public Func<string, Task<string>> AddNewAsync { get; set; } = (newValue) => Task.FromResult(newValue);
}
  • Be sure nullable is enable
  • Run the app
  • Type a letter and press backspace key to delete it.

Hosting Model (is this issue happening with a certain hosting model?):

  • Blazor Server

Version:
4.7.0

@oruchreis oruchreis added Bug Something isn't working Triage Issue needs to be triaged labels Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant