Description
Prerequisites
-
I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
There are two similar closed issues: 306 and 312. But the issue still exists. -
The issue still exists against the latest
master
branch of yii2-widget-select2. (version 2.1.9) -
This is not an usage question. I confirm having read the widget documentation and demos.
-
This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
-
This is not a source plugin (select2) issue. (Those should be directed to the plugin issues repo).
-
I have attempted to find the simplest possible steps to reproduce the issue.
-
I have included a failing test as a pull request (Optional).
Steps to reproduce the issue
- Run the widget
echo Select2::widget([ 'name' => 'state_10', 'data' => [ 'first'=>'One', 'second' => 'Two', 'thi-rd' => 'Three', 'fourth-' => 'Four'], 'options' => [ 'placeholder' => 'Select provinces ...', 'multiple' => true ], ]);
Expected behavior and actual behavior
When press 'Select all' - expecting behavior - select all options.
If some options' values have minus '-', 'Select All' doesn't select them. In the following example only 'One' and 'Two' will be selected. Even so, 'Three' and 'Four' can be selected manually one by one.
Environment
Browsers
- Google Chrome
- Mozilla Firefox
- Internet Explorer
- Safari
Operating System
- Windows
- Mac OS X
- Linux
- Mobile
Libraries
- jQuery version:
- yii2-widget-select2 version:
Isolating the problem
- This bug happens on the widget demos page
- The bug happens consistently across all tested browsers
- This bug happens when using yii2-widget-select2 without other plugins
- I can reproduce this bug in a jsbin
Workaround
Maybe this can help to resolve the issue - change 46 row of 'select2-krajee.js':
from val = $(this).attr('id').split('-').pop();
to [, val] = $(this).attr('id').match(/^select2-[^-]*-result-.{4}-(.*)$/);