Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Method to Force results dropdown to close? #293

@JGSilverman

Description

@JGSilverman

I'm have the following:

    <BlazoredTypeahead MinimumLength="4"
                                                       MaximumSuggestions="200"
                                                       SearchMethod="@(SearchDataSet)"
                                                       Value="@CurrentSelectedObject"
                                                       ValueChanged="@((MyObject value) => HandleAccountNum(value))"
                                                       ValueExpression="@(() => CurrentSelectedObject)"
                                                       TValue="MyObject "
                                                       TItem="MyObject" 
                                                       class="form-control"
                                                       @ref="txtAccountNum"
                                                       id="typeaheadBox"
                                                       tabindex="0">
                                            <SelectedTemplate Context="MyObject">
                                                <text>@MyObject.AccountNumber</text>
                                            </SelectedTemplate>
                                            <ResultTemplate Context="Ilmast">
                                                ...html
                                            </ResultTemplate>
</BlazoredTypeahead>

When I execute a search and get results back, if there's only one result, I automatically set that data set to CurrentSelectedObject which gets populated in the input. However, the typeahead-results dropdown remains (with one option in it), until the user physically selects it. Is there a method I can call to hide the results box (if I set results to empty, it shows the NotFound template).

 private async Task<IEnumerable<MyObject>> SearchDataSet(string searchText)
    {
        if (!string.IsNullOrEmpty(searchText))
        {
            var results = await _myService.FindByText(searchText);

            if (results.Count().Equals(1))
            {
                CurrentSelectedObject = results[0];
                /// need to hide the results from showing on the UI as there's only one option
            }

            return results;
        }
        else
        {
            return null;
        }
    }

Any help for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingTriageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions