@danielgindi/selectbox 2.0.46 → 2.0.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.es6.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 2.0.46
2
+ * @danielgindi/selectbox 2.0.48
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  import { createElement, closestUntil, setElementAttrs, next, prev } from '@danielgindi/dom-utils/lib/Dom';
@@ -715,16 +715,20 @@ class DropList {
715
715
  return false;
716
716
  }
717
717
 
718
- if (!p.multi) {
718
+ if (p.multi) {
719
+ if (this.hasFocusedItem()) {
720
+ this.toggleFocusedItem();
721
+ }
722
+ } else {
719
723
  this._setSingleSelectedItemEl(p.focusItemEl);
720
- }
721
724
 
722
- this._trigger('select', {
723
- value: item ? item.value : undefined,
724
- item: item[ItemSymbol] ?? item,
725
- event: event,
726
- el: p.focusItemEl,
727
- });
725
+ this._trigger('select', {
726
+ value: item ? item.value : undefined,
727
+ item: item[ItemSymbol] ?? item,
728
+ event: event,
729
+ el: p.focusItemEl,
730
+ });
731
+ }
728
732
 
729
733
  return true;
730
734
  }
@@ -2075,7 +2079,7 @@ class DropList {
2075
2079
  }
2076
2080
 
2077
2081
  hasFocusedItem() {
2078
- return this._p.focusItemIndex > -1;
2082
+ return this._p.focusItemIndex > -1 && this._p.focusItemIndex < this._p.items.length;
2079
2083
  }
2080
2084
 
2081
2085
  getFocusedItemIndex() {
@@ -2503,8 +2507,6 @@ class DropList {
2503
2507
  if (this[DestroyedSymbol$1])
2504
2508
  return;
2505
2509
 
2506
- this.toggleFocusedItem();
2507
-
2508
2510
  if (document.activeElement !== this.el && p.focusItemEl) {
2509
2511
  clearTimeout(p.blurTimer);
2510
2512
  }