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

Add Item on Select #1164

Closed
noctivityinc opened this issue Aug 1, 2024 · 10 comments · Fixed by #1166
Closed

Add Item on Select #1164

noctivityinc opened this issue Aug 1, 2024 · 10 comments · Fixed by #1166

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 [...]

Very much so. When an item is not in the select list we need an option to let them add the typed string. This is common practice in things like select2

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

addItem: true should be supported for select lists and then the addItem event should just accept whatever was entered just like with list = text

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

Adding a new button next to the list, which is a weird UX for people to stop to have to click it

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

If you cant do this easily, at least add support for the No items Found label to trigger an event that we can then use to handle this.

@noctivityinc
Copy link
Author

It seems like all we would really need here is an event around line 863 in choices.ts to make this happen, right?

@Xon
Copy link
Collaborator

Xon commented Aug 2, 2024

I've been working on a fork which implements this; https://github.com/Xon/Choices.js

My fork doesn't have the testing pipeline setup, but in the examples and my own usage it doesn't appear to be hitting noticeable bugs.

I've just tagged a release which I believe should be stable; https://github.com/Xon/Choices.js/releases/tag/v11.0.0RC1

@noctivityinc
Copy link
Author

@Xon this is most excellent. Any specific documentation related to this I need to follow? Just downloaded the zip of the code and will try to install your source code directly. Do I need the images fold?

@noctivityinc
Copy link
Author

@Xon two issues Im seeing:

  1. When you create something new, it gets appended to the text box instead of replacing it.

Screenshot 2024-08-02 at 9 34 10 AM
(Build above was the first option, the This is new was the new option I typed and hit enter)

  1. There is no indication int he addItem event fired that this is a new item. I need to either check that label is an object or the like. Would be a good idea to maybe have a flag.

@noctivityinc
Copy link
Author

It looks like the previous selected item is not being removed:

Screenshot 2024-08-02 at 9 42 38 AM

@Xon
Copy link
Collaborator

Xon commented Aug 2, 2024

It looks like there is a bug with the select-one and the item entering.

I've largely been using select-multiple with the new singleModeForMultiSelect flag.

@noctivityinc
Copy link
Author

@Xon let me know when fixed and Ill be happy to continue my testing. Great work so far!

@Xon
Copy link
Collaborator

Xon commented Aug 2, 2024

I believe I've fixed the select-one bugs, but there is some undesirable/buggy behavior I'm not going to be able to easily fix. If you do find any more issues, please open an issue on my fork's repo.

The new select choice code was something I merged in from an outstanding pull request, and runs into limitations of how choices.js is doing the UI control for that aspect.

Essentially it needs an explicit state machine to control were and how input is being processed and the various UI states it enables/disables. This sadly is something which need more time to be worked on.

@noctivityinc
Copy link
Author

Thanks. Was there an alternative library you considered instead of this you think is worth looking at?

@Xon
Copy link
Collaborator

Xon commented Aug 6, 2024

@noctivityinc I've tagged v11.0.0RC4 which contains bugfixes for various select-one issues you experianced.

I've been granted merge access to this repo and I'm working through fixing the broken tests and getting the above changes merged in.

@Xon Xon added the WIP label Aug 6, 2024
@Xon Xon linked a pull request Aug 6, 2024 that will close this issue
9 tasks
@Xon Xon closed this as completed Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants