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

Added possibility to add an item when no item is found #215

Merged
merged 1 commit into from
Mar 22, 2021

Conversation

matijs-toonen
Copy link
Contributor

@matijs-toonen matijs-toonen commented Mar 17, 2021

Situation

I would like to have the possibility to add an item using the typeahead component without the need to submit a form with all its data. This would be useful in cases like a label which is nothing more than plain text.

Description

This PR will add a new parameter to the typeahead component called AddItemOnEmptyResultMethod,
the parameter will change the NotFoundTemplate to be a selectable item just like the search results, this item will however use the NotFoundTemplate as the Template instead of the ResultTemplate.

Warning

This adds a context to the NotFoundTemplate and will therefore not work out of the box when updating, this context is added to let the user create the template with the search input. The searchinput can then be used within the template for extra possibilities.
The context is not necessary and can be removed if requested, but is quite useful to fil the template with a placeholder like Add "SearchInput" as a new label

Copy link
Member

@chrissainty chrissainty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is some great work @matijs-toonen! I've just got one change request but then it's ready to merge. This will make a lot of people very happy!

samples/BlazorServer/BlazorServer.csproj Outdated Show resolved Hide resolved
@kinetiq
Copy link

kinetiq commented Mar 22, 2021

@chrissainty Cindy found this PR, and wondered if this might indirectly address the need we were talking about on Twitter. To recap, we want users to be able to type text into the TypeAhead that does not exist in the list, and potentially use that. Currently we do have a way to get at that text, but if the TypeAhead loses focus, the text is cleared, which is a very bumpy UX and clearly not something you are currently trying to support.

Any thoughts?

@chrissainty
Copy link
Member

Hey @kinetiq. Yes Cindy messaged me earlier and I pointed her at this PR. It was a very odd, but great, coincidence this popped up when it did. It seems to me like it would solve your issue. @matijs-toonen did some great work here.

@chrissainty chrissainty merged commit f7ef8fb into Blazored:main Mar 22, 2021
@chrissainty
Copy link
Member

Thanks for this great feature @matijs-toonen! :shipit:

@kinetiq
Copy link

kinetiq commented Mar 22, 2021

Well that case - thanks @matijs-toonen, what a wonderful coincidence. :) I really appreciate your contribution. Turns out it will solve a headache for my team.

Chris, any idea when this will be available in nuget?

timbze pushed a commit to timbze/Typeahead that referenced this pull request Mar 22, 2021
@matijs-toonen matijs-toonen deleted the AddItemOnEmpty branch March 23, 2021 07:11
@chrissainty
Copy link
Member

@kinetiq I plan on getting this released today.

@chrissainty chrissainty added the Feature New feature that will be added to the project label Mar 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Feature New feature that will be added to the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants