Creating a new tag with a value equal to the id of an existing option causes both the new tag and the existing option to be added as selections
Open
Nobody has claimed this yet.
4.x
confirmed bug
feature: multi-select
feature: selections
feature: tagging
help wanted
- Dominant language
- JavaScript
- Stars
- 25.9k
- Forks
- 6.1k
- Avg merge
- 8d 53m
- Merged PRs (30d)
- 4
Description
// input: red,
// var_dump($_POST["colors"]);
Array
(
[0] => red
[1] => red
)
// input: apple,green,water,
// var_dump($_POST["colors"]);
Array
(
[0] => green
[1] => green
)
// input: red,green,blue,yellow,
// var_dump($_POST["colors"]);
Array
(
[0] => red
[1] => green
[2] => blue
[3] => yellow
[4] => red
)
<select name="colors[]" id="tags-example" multiple="multiple">
<option value="red">apple</option>
<option value="green">grass</option>
<option value="blue">water</option>
<option value="yellow">sun</option>
</select>
$('#tags-example').select2({
tags: true,
tokenSeparators: [',', ' '],
maximumSelectionLength: 2
});
Please see the following fiddle to see what happens:
http://jsfiddle.net/o1je0988/
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked jsFiddle and reproduce the issue using the #tags-example select initialized with tags, tokenSeparators, and maximumSelectionLength. Trace the tag and option selection handling, then verify that entering an existing option value creates only one selection in each reported input case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, jquery
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100