Skip to content

Commit 9d4155d

Browse files
committed
Merge remote-tracking branch 'refs/remotes/Scottmitch1/issue_423'
2 parents 28d56e9 + 0bc0b63 commit 9d4155d

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

src/selectize.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ $.extend(Selectize.prototype, {
12871287
var $item, $option, $options;
12881288
var self = this;
12891289
var inputMode = self.settings.mode;
1290-
var i, active, value_next;
1290+
var i, active, value_next, wasFull;
12911291
value = hash_key(value);
12921292

12931293
if (self.items.indexOf(value) !== -1) {
@@ -1300,15 +1300,18 @@ $.extend(Selectize.prototype, {
13001300
if (inputMode === 'multi' && self.isFull()) return;
13011301

13021302
$item = $(self.render('item', self.options[value]));
1303+
wasFull = self.isFull();
13031304
self.items.splice(self.caretPos, 0, value);
13041305
self.insertAtCaret($item);
1305-
self.refreshState();
1306+
if (!self.isPending || (!wasFull && self.isFull())) {
1307+
self.refreshState();
1308+
}
13061309

13071310
if (self.isSetup) {
13081311
$options = self.$dropdown_content.find('[data-selectable]');
13091312

13101313
// update menu / remove the option (if this is not one item being added as part of series)
1311-
if (!this.isPending) {
1314+
if (!self.isPending) {
13121315
$option = self.getOption(value);
13131316
value_next = self.getAdjacentOption($option, 1).attr('data-value');
13141317
self.refreshOptions(self.isFocused && inputMode !== 'single');
@@ -1318,7 +1321,7 @@ $.extend(Selectize.prototype, {
13181321
}
13191322

13201323
// hide the menu if the maximum number of items have been selected or no options are left
1321-
if (!$options.length || (self.settings.maxItems !== null && self.items.length >= self.settings.maxItems)) {
1324+
if (!$options.length || self.isFull()) {
13221325
self.close();
13231326
} else {
13241327
self.positionDropdown();
@@ -1757,17 +1760,19 @@ $.extend(Selectize.prototype, {
17571760
i = Math.max(0, Math.min(self.items.length, i));
17581761
}
17591762

1760-
// the input must be moved by leaving it in place and moving the
1761-
// siblings, due to the fact that focus cannot be restored once lost
1762-
// on mobile webkit devices
1763-
var j, n, fn, $children, $child;
1764-
$children = self.$control.children(':not(input)');
1765-
for (j = 0, n = $children.length; j < n; j++) {
1766-
$child = $($children[j]).detach();
1767-
if (j < i) {
1768-
self.$control_input.before($child);
1769-
} else {
1770-
self.$control.append($child);
1763+
if(!self.isPending) {
1764+
// the input must be moved by leaving it in place and moving the
1765+
// siblings, due to the fact that focus cannot be restored once lost
1766+
// on mobile webkit devices
1767+
var j, n, fn, $children, $child;
1768+
$children = self.$control.children(':not(input)');
1769+
for (j = 0, n = $children.length; j < n; j++) {
1770+
$child = $($children[j]).detach();
1771+
if (j < i) {
1772+
self.$control_input.before($child);
1773+
} else {
1774+
self.$control.append($child);
1775+
}
17711776
}
17721777
}
17731778

0 commit comments

Comments
 (0)