Commit 21225a84 authored by David Stutz's avatar David Stutz

Merge pull request #406 from KyleNeedham/fix-405

Fixes #405
parents 4da7b531 902b7216
......@@ -456,6 +456,13 @@
var $target = $(event.target);
if (document.getSelection().type === 'Range') {
var $input = $(this).find("input:first");
$input.prop("checked", !$input.prop("checked"))
.trigger("change");
}
if (event.shiftKey) {
var checked = $target.prop('checked') || false;
......
......@@ -3880,11 +3880,6 @@ $('.multiselect').multiselect({
<dd>
See issue <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/396"></a>. Pull requests are welcome.
</dd>
<dt>Unable to select an option while text is selected.</dt>
<dd>
As reported in <a href="https://github.com/davidstutz/bootstrap-multiselect/issues/405">#405</a> this seems to be restricted to several Chrome builds.
</dd>
</dl>
<div class="page-header">
......
......@@ -573,4 +573,35 @@ describe('Bootstrap Multiselect Specific Issues', function() {
$('#multiselect').multiselect('destroy');
$('#multiselect').remove();
});
});
\ No newline at end of file
it('#405', function() {
var selection = document.getSelection();
var range = document.createRange();
var $selection = $('<span>Some text to select</span>');
var $select = $('<select id="multiselect" multiple="multiple"></select>');
for (var i = 1; i < 5; i++) {
$select.append('<option value="' + i + '">select option</option>');
}
$('body').append($selection).append($select);
$select.multiselect({
buttonContainer: '<div id="multiselect-container"></div>',
});
range.selectNodeContents($selection.get(0));
selection.removeAllRanges();
selection.addRange(range);
if (document.getSelection().type === 'Range') {
$('#multiselect-container').find('a:first').trigger('click');
expect($('#multiselect-container').find('input:first').prop('checked')).toBe(true);
}
$('#multiselect').multiselect('destroy');
$('#multiselect').remove();
$selection.remove();
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment