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

Selectize does not work for addOption() with option value=null #1648

Open
3 of 5 tasks
FritzHerbers opened this issue Jul 29, 2021 · 3 comments
Open
3 of 5 tasks

Selectize does not work for addOption() with option value=null #1648

FritzHerbers opened this issue Jul 29, 2021 · 3 comments
Labels
needs-thought pending review This issue was closed as stale; since then additional review has been requested.

Comments

@FritzHerbers
Copy link

I did:

  • Search for if my issue has already been submitted
  • Make sure I'm reporting something precise that needs to be fixed
  • Give my issue a descriptive and concise title
  • Create a minimal working example on JsFiddle or Codepen
    (or gave a link to a demo on the Selectize docs)
  • Indicate precise steps to reproduce in numbers and the result,
    like below

[replace me with a short description of issue]

Steps to reproduce:

Expected result:
Having the possibility to add an option with value=null to be added with addOption()

Actual result:
selectize does not allow to add an option with value=null with addOption().

When using selectize in html mode value=null seems to work: https://jsfiddle.net/v79613p4/

I am using Angular with ng-selectize, which uses selectize.
I could identify the problem in addOption():

registerOption: function(data) {
	var key = hash_key(data[this.settings.valueField]);
	if (typeof key === 'undefined' || key === null || this.options.hasOwnProperty(key)) return false;
	data.$order = data.$order || ++this.order;
	this.options[key] = data;
	return key;
},

When typeof key === 'undefined' || key === null || is removed the option can be added and is visible, but now the option can not really be selected, the select dropdown box stays open. The box closes only when a 'valid' option is choosen.

I do not have experience of setting up a selectize/javascript project. I have been searching for jsfiddle/codepen examples to kickstart and narrow down the issue, haven't found any. It would be nice when the project could create some for the demos, which then can be used as a starting point.

@github-actions
Copy link
Contributor

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days

@FritzHerbers
Copy link
Author

The issue is about to close, can I please have your thoughts about this issue.

@github-actions
Copy link
Contributor

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days

@risadams risadams added needs-thought pending review This issue was closed as stale; since then additional review has been requested. and removed no-issue-activity labels Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-thought pending review This issue was closed as stale; since then additional review has been requested.
Projects
None yet
Development

No branches or pull requests

2 participants