Skip to content

Commit

Permalink
Merge PR #755
Browse files Browse the repository at this point in the history
  • Loading branch information
joallard committed Jul 27, 2016
2 parents 5a59ef6 + 645e04a commit e4cf453
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ $.extend(Selectize.prototype, {
var timeout_focus;
var classes;
var classes_plugins;
var inputId;

inputMode = self.settings.mode;
classes = $input.attr('class') || '';
Expand All @@ -126,6 +127,11 @@ $.extend(Selectize.prototype, {
$dropdown = $('<div>').addClass(settings.dropdownClass).addClass(inputMode).hide().appendTo($dropdown_parent);
$dropdown_content = $('<div>').addClass(settings.dropdownContentClass).appendTo($dropdown);

if(inputId = $input.attr('id')) {
$control_input.attr('id', inputId + '-selectized');
$('label[for='+inputId+']').attr('for', inputId + '-selectized');
}

if(self.settings.copyClassesToDropdown) {
$dropdown.addClass(classes);
}
Expand Down
37 changes: 37 additions & 0 deletions test/interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,43 @@

});

describe('clicking label', function() {

it('should give it focus to select', function(done) {
var inputId = "labeledSelect";
var label =
$('<label for="'+inputId+'">select</label>').appendTo('form');

var test = setup_test('<select id="'+inputId+'">' +
'<option value="a">A</option>' +
'<option value="b">B</option>' +
'</select>', {});

syn.click(label)
.delay(0, function() {
label.remove();
expect(test.selectize.isFocused).to.be.equal(true);
done();
});
});

it('should give it focus to input', function(done) {
var inputId = "labeledInput";
var label =
$('<label for="'+inputId+'">input</label>').appendTo('form');

var test = setup_test('<input id="'+inputId+'" type="text" value="a,b,c,d">', {});

syn.click(label)
.delay(0, function() {
label.remove();
expect(test.selectize.isFocused).to.be.equal(true);
done();
});
});

});

describe('clicking option', function() {

it('should select it', function(done) {
Expand Down

0 comments on commit e4cf453

Please sign in to comment.