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

Select2 expects provider to always give an answer #101

Open
Stijnvdk opened this issue Nov 10, 2014 · 0 comments
Open

Select2 expects provider to always give an answer #101

Stijnvdk opened this issue Nov 10, 2014 · 0 comments

Comments

@Stijnvdk
Copy link

The Select2Choice class in the convertInput method expects the provider to give an answer given an input on line 54:

setConvertedInput(getProvider().toChoices(Collections.singleton(input)).iterator().next());

If you update the contents of the Select2 via Ajax and the backing model has updated but the front end has not, it can be possible for the Select2 to send a meaningless input to the server. The provider getProvider() is expected to always return an option server side, while the input might not have made sense.

Instead of calling iterator().next() it should check if there is indeed an answer, if the backing provider finds the input valid.

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

No branches or pull requests

1 participant