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

Typeahead: Is there a way to unselect current item on focus? #115

Open
toseni opened this issue May 12, 2022 · 1 comment · May be fixed by #97
Open

Typeahead: Is there a way to unselect current item on focus? #115

toseni opened this issue May 12, 2022 · 1 comment · May be fixed by #97
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@toseni
Copy link

toseni commented May 12, 2022

Prerequisite: Have some item selected on TypeaheadInput.

When clicking on TypeaheadInput to focus it, TypeaheadInput leaves current item selected and places cursor at the end of item label.

Is there a way to change this behaviour, so that focus on TypeaheadInput would 1) unselect current item 2) clear search text 3) open dropdown?

@majorimi
Copy link
Owner

Hi @toseni,

Thanks for contacting me and sorry for the delay.
I have tested Typeahead and at first was not able to reproduce your application behavior. Typeahead was opening the dropdown when it got focus.

But then reached the example "Typeahead async custom search method set to DataSource property as Func<string, Task<IEnumerable>>"
Do you use this?

Because in this case data source is the result of an async method (e.g. server response). Opening the popup requires the search method to return values. It would not be optimal. And even yourself was mentioning 3 different behaviors. So it would be hard to decide which one is best for everyone.

For now what you might can do is to use IEnumerable<TItem> Data not the async DataSource by getting your values on component init, etc.

Later what I can do and the simplest is to expose OnFocus EventCallback which you can subscribe and trigger your on behavior. So if you wish you can trigger a new search, clear value, etc...

@majorimi majorimi self-assigned this May 30, 2022
@majorimi majorimi added enhancement New feature or request question Further information is requested labels May 30, 2022
@majorimi majorimi linked a pull request May 30, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
Blazor Components
  
Awaiting triage
Development

Successfully merging a pull request may close this issue.

2 participants