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

Select-2 does not set _hasSelectedMissingItems back to false when setting "value" to null #120

Open
FredUK opened this issue Aug 19, 2015 · 2 comments

Comments

@FredUK
Copy link

FredUK commented Aug 19, 2015

When select-2 detects that the selected "value" property no longer exists in "content" it sets itself to _hasSelectedMissingItems = true, disabling the element and throws the warning:

WARNING: select2#initSelection was not able to map each "identity" to an object from "content". The      remaining keys are: 4278905e-5ee2-0b96-9810-64aa7a3e16a7. The input will be disabled until a) the     desired objects is added to the "content" array or b) the "value" is changed."

It seems the input will only be re-enabled if the "value" is set to one of the remaining keys.
However one should be able to set the "value" back to null so that the input would still be re-enabled but without selecting any option.

When the input is disabled because the "value" is invalid, it should re-enable it when we reset "value" back to null, but this is not happening.

@jurgenwerk
Copy link

@FredUK I'm also having issues with this when I try to change content of the dropdown component when some value has already been selected. Then the dropdown becomes disabled. Have you perhaps found a quick fix for this or can point me towards on how to make one in the add-on code? Thanks!

@jurgenwerk
Copy link

I solved it with this stupid hack in initSelection. It resets the input after content from computed property has been changed and selected value is no longer in the content. Works for me. ¯_(ツ)_/¯

var contentIds = content.map(function (item) { return item.id });
var valuePresentInIds = contentIds.indexOf(value) != -1;

if (!value || !value.length || !valuePresentInIds) {
  return callback([]);
}

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

2 participants