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

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working Triage Issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

1 participant