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

Method to Force results dropdown to close? #293

Open
JGSilverman opened this issue Oct 12, 2022 · 0 comments
Open

Method to Force results dropdown to close? #293

JGSilverman opened this issue Oct 12, 2022 · 0 comments
Labels
Bug Something isn't working Triage Issue needs to be triaged

Comments

@JGSilverman
Copy link

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?

@JGSilverman JGSilverman added Bug Something isn't working Triage Issue needs to be triaged labels Oct 12, 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