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

Allow users to create new if not found #432

Open
noctivityinc opened this issue Jul 31, 2024 · 3 comments
Open

Allow users to create new if not found #432

noctivityinc opened this issue Jul 31, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@noctivityinc
Copy link

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

No. The library is amazing!

Thoroughly Describe the solution you'd like
A clear and concise description of what you want to happen.

Im surprised I dont see this already in here as it's pretty standard for tags and the like. If the user types something that doesnt exit, I need there to be an option to "Add _____ as new tag" that would then submit a function with the value.

Screenshot 2024-07-31 at 9 11 11 AM

Please provide a few use cases for this feature

  1. Tags
  2. Product List
  3. Todos
  4. Infinite uses

Please Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

I can add a small + button NEXT to the list to create a new option, but that's not nearly as efficient in the workflow

Additional context
Add any other context or screenshots about the feature request here.

@noctivityinc noctivityinc added the enhancement New feature or request label Jul 31, 2024
@TarekRaafat
Copy link
Owner

Hello @noctivityinc,

Thanks for your suggestion!

I'll make sure I got you right. You're looking forward to customizing the no-results condition by adding actions. You can do that through the noResults configuration if that's the case. Please check it on this link and let me know if that's what you're looking for.

Have a nice day!

@noctivityinc
Copy link
Author

@TarekRaafat worked great, thanks!

@noctivityinc
Copy link
Author

@TarekRaafat I spoke too soon.

While it DOES work to let me trigger an event to create a new item, there doesnt appear to be a way for me to refresh the data attribute with an updated source so that the new item appears the next time the user searches the list.

For example, assume this flow:

  1. User starts to type something not in the list
  2. resultsLst see there are no results so a new element is added with a click even attached to create a new item based on what they typed.
  3. User clicks the new element and the event creates the new item in the backend.
  4. User decides to change their selection to something else
  5. User then goes back wanted to select the item they created in step 3 and they cant because that item was never added!

I COULD create a new dom element and add it to the list, but that doesnt change the selection event, which returns an object from the data, not the actual dom element selected. Since the new element isnt in the data I'm stuck.

What we need is something like

`autoComplete.append([{id: 123, name: 'New Item'}]) that would let us add something new to the list and then refresh the data.

Any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants