Skip to content

Commit

Permalink
Fixed bug causing open() to not give control proper focus.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianreavis committed Jul 29, 2013
1 parent d7eab47 commit 0a5959a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -1385,14 +1385,16 @@ $.extend(Selectize.prototype, {
* Updates all state-dependent CSS classes.
*/
refreshClasses: function() {
var isFull = this.isFull();
var isLocked = this.isLocked;
var self = this;
var isFull = self.isFull();
var isLocked = self.isLocked;
this.$control
.toggleClass('focus', this.isFocused)
.toggleClass('disabled', this.isDisabled)
.toggleClass('focus', self.isFocused)
.toggleClass('disabled', self.isDisabled)
.toggleClass('locked', isLocked)
.toggleClass('full', isFull).toggleClass('not-full', !isFull)
.toggleClass('has-items', this.items.length > 0);
.toggleClass('dropdown-active', self.isOpen)
.toggleClass('has-items', self.items.length > 0);
this.$control_input.data('grow', !isFull && !isLocked);
},

Expand Down Expand Up @@ -1456,10 +1458,10 @@ $.extend(Selectize.prototype, {
var self = this;

if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull())) return;
self.focus();
self.focus(true);
self.isOpen = true;
self.refreshClasses();
self.$dropdown.css({visibility: 'hidden', display: 'block'});
self.$control.addClass('dropdown-active');
self.positionDropdown();
self.$dropdown.css({visibility: 'visible'});
self.trigger('dropdown_open', this.$dropdown);
Expand All @@ -1473,9 +1475,9 @@ $.extend(Selectize.prototype, {

if (!self.isOpen) return;
self.$dropdown.hide();
self.$control.removeClass('dropdown-active');
self.setActiveOption(null);
self.isOpen = false;
self.refreshClasses();
self.trigger('dropdown_close', self.$dropdown);
},

Expand Down

0 comments on commit 0a5959a

Please sign in to comment.