Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.3k stars 533 forks source link

Autocomplete: Able to type freely #1485

Closed David-Moreira closed 3 years ago

David-Moreira commented 3 years ago

Is your feature request related to a problem? Please describe. I imagine a use case will be that autocomplete just augments the writing providing "suggestions". I think that it would be a nice to have, to be able to still freely type a value outside of the AutoComplete Data Values.

Another nice to have feature (Open another feature request if needed), is to have it display all available values on click with a scroll bar if there's alot of values. Then, if you type, it starts filtering the results.

Describe the solution you'd like Seems like a flag for both these features would be a nice to have.

stsrki commented 3 years ago

So having a custom filter method that Autocomplete would use?

I like both ideas :)

adamkf commented 3 years ago

I'm looking for this feature as well. I'm looking for a solution to the use case where a user is asked to enter a vendor name into a component (eg: Autocomplete). As they type, the list of vendors is refined and suggestions provided.

If the typed vendor is ultimately not in the search dataset, the component will raise an event, or provide access to the text field so we can wire up the vendor creation process.

Correct me if I'm wrong but the Autcomplete component doesn't let me do this today, correct?

stsrki commented 3 years ago

@adamkf No, this is not possible. Your idea to have an event when something is not found seems like a good solution.

paulosdfigueiredo commented 3 years ago

Maybe Autocomplete should have a "NotFoundTemplate" RenderFragment with the text as context.

This way we could add some message or add a button or whatever we want.

stsrki commented 3 years ago

So to summarize

Todo proposals:

David-Moreira commented 3 years ago

I didn't even remember about opening this issue anymore 😅also #1890 could have some interesting features to further consider / augment autocomplete

adamkf commented 3 years ago

@stsrki Cheers for the quick response mate, did not expect immediate attention (especially with the 0.9.3 release!)

ToDo looks good. I'd add that given TValue would likely be null in such a case, we should probably expose a property that returns the current value of the text field so we can interact either via the event, or plumb something up via a new text property.

NotFound event callback should provide the current text.

stsrki commented 3 years ago

We already have SearchChanged callback.

adamkf commented 3 years ago

True, I'm still wrapping my head around how Blazor components pass info back and forth (still a bit new to me)

WayneHiller commented 3 years ago

I copied the Autocomplete source and was able to get free typing working by just making the SelectedText a Parameter and adding a SelectedTextChanged event. I now just bind to SelectedText when I want free entry. I had to add calling the SelectedTextChanged event in a few places. Now the harder part is I would like to get standard validation (with annotations too) working on the SelectedText

mtbayley commented 3 years ago

Also would love to have this feature 🙂

WayneHiller commented 3 years ago

@mtbayley I created a copy of the Autocomplete and added this functionality, can send it to you if you want it.

stsrki commented 3 years ago

@WayneHiller you can also post it here :)

WayneHiller commented 3 years ago

I noted the changes I made to the original files with // WH comments.

AlliedAutocomplete.razor.zip