@danielgindi/selectbox 2.0.49 → 2.0.51

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.49
2
+ * @danielgindi/selectbox 2.0.51
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  import { createElement, closestUntil, setElementAttrs, next, prev } from '@danielgindi/dom-utils/lib/Dom';
@@ -4796,7 +4796,8 @@ class SelectBox {
4796
4796
 
4797
4797
  this._trigger('open:before', { list: p.dropList });
4798
4798
 
4799
- p.lastActiveElement = document.activeElement === document.body ? null : getFocusState(document.activeElement);
4799
+ if (document.activeElement !== p.input)
4800
+ p.lastActiveElement = document.activeElement === document.body ? null : getFocusState(document.activeElement);
4800
4801
 
4801
4802
  // Propagate direction to droplist
4802
4803
  p.dropList.setDirection(getComputedStyle(p.el).direction);
@@ -4833,7 +4834,8 @@ class SelectBox {
4833
4834
  p.dropList.hide();
4834
4835
 
4835
4836
  if (p.lastActiveElement) {
4836
- restoreFocusState(p.lastActiveElement);
4837
+ if (!p.multi && !p.searchable)
4838
+ restoreFocusState(p.lastActiveElement);
4837
4839
  p.lastActiveElement = null;
4838
4840
  }
4839
4841
 
@@ -6624,10 +6626,12 @@ class SelectBox {
6624
6626
  event.preventDefault();
6625
6627
  } else if (event.key === VALUE_BACK_SPACE && target.value.length === 0) {
6626
6628
  const itemEl = p.multiItemEls[p.multiItemEls.length - 1];
6627
- if (!itemEl || itemEl[ItemSymbol].value === undefined)
6629
+ if (!itemEl)
6628
6630
  return;
6629
6631
 
6630
6632
  const item = itemEl[ItemSymbol], value = item[p.valueProp];
6633
+ if (value === undefined)
6634
+ return;
6631
6635
 
6632
6636
  let removeselEvt = { value: value, item: item, cancel: false };
6633
6637
  this._trigger('removesel:before', removeselEvt);