@danielgindi/selectbox 1.0.131 → 1.0.133

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.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 1.0.131
2
+ * @danielgindi/selectbox 1.0.133
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  'use strict';
@@ -2862,6 +2862,24 @@ class DropList {
2862
2862
  return false;
2863
2863
  }
2864
2864
 
2865
+ /**
2866
+ * Returns true if document's active element is this droplist (or owned submenus)
2867
+ * @param {boolean} [considerSubmenus=true]
2868
+ * @returns {boolean}
2869
+ */
2870
+ hasFocus() {var _this$_p$currentSubDr2;let considerSubmenus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
2871
+ if (!document.activeElement)
2872
+ return false;
2873
+
2874
+ if (document.activeElement.contains(this.el))
2875
+ return true;
2876
+
2877
+ if (considerSubmenus && (_this$_p$currentSubDr2 = this._p.currentSubDropList) !== null && _this$_p$currentSubDr2 !== void 0 && (_this$_p$currentSubDr2 = _this$_p$currentSubDr2.droplist) !== null && _this$_p$currentSubDr2 !== void 0 && _this$_p$currentSubDr2.hasFocus())
2878
+ return true;
2879
+
2880
+ return false;
2881
+ }
2882
+
2865
2883
  /**
2866
2884
  * @param {string|string[]} classes
2867
2885
  * @returns {DropList}
@@ -3902,9 +3920,6 @@ class DropList {
3902
3920
  }).
3903
3921
  on('_back_key_pressed', () => {
3904
3922
  this._hideSublist();
3905
-
3906
- if (!this[DestroyedSymbol$1])
3907
- this.el.focus();
3908
3923
  });
3909
3924
 
3910
3925
  droplist.setItems(item._subitems);
@@ -3921,7 +3936,7 @@ class DropList {
3921
3936
  position: { x: 'start', y: 'top' },
3922
3937
  anchor: { x: 'end', y: 'top' },
3923
3938
  offset: { x: 0, y: 0 },
3924
- updateWidth: true
3939
+ updateWidth: false
3925
3940
  });
3926
3941
 
3927
3942
  p.currentSubDropList = {
@@ -3940,10 +3955,17 @@ class DropList {
3940
3955
  return;
3941
3956
 
3942
3957
  const data = p.currentSubDropList;
3958
+
3959
+ let subHadFocus = data.droplist.hasFocus(true);
3960
+
3943
3961
  data.droplist.hide();
3944
3962
  data.droplist.destroy();
3945
3963
  p.currentSubDropList = null;
3946
3964
 
3965
+ if (subHadFocus && !this[DestroyedSymbol$1]) {
3966
+ this.el.focus();
3967
+ }
3968
+
3947
3969
  this._trigger('hide_subitems', {
3948
3970
  value: data.item.value,
3949
3971
  item: data.item,