Blazored / Typeahead

Typeahead control for Blazor applications
https://blazored.github.io/Typeahead/
MIT License
439 stars 103 forks source link

[Question] #255

Closed sajrashid closed 2 years ago

sajrashid commented 2 years ago

Hi,

In multi-select mode, I'm unable to hit the ValueChanged event, if I remove @bind-Values the event triggers, but multi-select is removed, I don't know what am I doing wrong,?

Help appreciated, Thanks.

<BlazoredTypeahead class="bg-blue-500 text-gray-100" SearchMethod="GetRepos"
                                @bind-Values="SelectedRepositories"

                               Debounce="100" MaximumSuggestions="20"
                               Value="selectedRepo"
                               TItem="Repo"
                               TValue="Repo"
                               ValueChanged="@( (Repo r) =>SelectedResultChanged(r) )"
                               ValueExpression="@(() => selectedRepo)"
                               EnableDropDown="true"
                               placeholder="Search by name...">
                <SelectedTemplate Context="Repo">
                    @Repo.Name
                </SelectedTemplate>
                <ResultTemplate   Context="Repo">
                    @Repo.Name (Id: @Repo.Id)
                </ResultTemplate>
            </BlazoredTypeahead>
    private IList<Repo>? SelectedRepositories;

    private async Task SelectedResultChanged(Repo repo)
        {
            selectedRepo = repo;
            Console.WriteLine(repo.Name);
        }
chrissainty commented 2 years ago

You can't use bind-Value and ValueChanged. If you remove bind-Value and provide a value for the Value parameter then it will work.