@@ -1287,7 +1287,7 @@ $.extend(Selectize.prototype, {
1287
1287
var $item , $option , $options ;
1288
1288
var self = this ;
1289
1289
var inputMode = self . settings . mode ;
1290
- var i , active , value_next ;
1290
+ var i , active , value_next , wasFull ;
1291
1291
value = hash_key ( value ) ;
1292
1292
1293
1293
if ( self . items . indexOf ( value ) !== - 1 ) {
@@ -1300,15 +1300,18 @@ $.extend(Selectize.prototype, {
1300
1300
if ( inputMode === 'multi' && self . isFull ( ) ) return ;
1301
1301
1302
1302
$item = $ ( self . render ( 'item' , self . options [ value ] ) ) ;
1303
+ wasFull = self . isFull ( ) ;
1303
1304
self . items . splice ( self . caretPos , 0 , value ) ;
1304
1305
self . insertAtCaret ( $item ) ;
1305
- self . refreshState ( ) ;
1306
+ if ( ! self . isPending || ( ! wasFull && self . isFull ( ) ) ) {
1307
+ self . refreshState ( ) ;
1308
+ }
1306
1309
1307
1310
if ( self . isSetup ) {
1308
1311
$options = self . $dropdown_content . find ( '[data-selectable]' ) ;
1309
1312
1310
1313
// 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 ) {
1312
1315
$option = self . getOption ( value ) ;
1313
1316
value_next = self . getAdjacentOption ( $option , 1 ) . attr ( 'data-value' ) ;
1314
1317
self . refreshOptions ( self . isFocused && inputMode !== 'single' ) ;
@@ -1318,7 +1321,7 @@ $.extend(Selectize.prototype, {
1318
1321
}
1319
1322
1320
1323
// 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 ( ) ) {
1322
1325
self . close ( ) ;
1323
1326
} else {
1324
1327
self . positionDropdown ( ) ;
@@ -1757,17 +1760,19 @@ $.extend(Selectize.prototype, {
1757
1760
i = Math . max ( 0 , Math . min ( self . items . length , i ) ) ;
1758
1761
}
1759
1762
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
+ }
1771
1776
}
1772
1777
}
1773
1778
0 commit comments