autoComplete.js icon indicating copy to clipboard operation
autoComplete.js copied to clipboard

Allow users to create new if not found

Open noctivityinc opened this issue 1 year ago • 3 comments

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 avatar Jul 31 '24 13:07 noctivityinc

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!

TarekRaafat avatar Aug 03 '24 10:08 TarekRaafat

@TarekRaafat worked great, thanks!

noctivityinc avatar Aug 06 '24 00:08 noctivityinc

@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?

noctivityinc avatar Aug 06 '24 00:08 noctivityinc