@danielgindi/selectbox 1.0.138 → 1.0.140

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.138
2
+ * @danielgindi/selectbox 1.0.140
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  'use strict';
@@ -1805,11 +1805,12 @@ class DropList {
1805
1805
  setTimeout(() => {
1806
1806
  if (this[DestroyedSymbol$1]) return;
1807
1807
 
1808
- if (!document.activeElement ||
1809
- !this.elContains(document.activeElement, true)) {
1810
- this._delayBlurItemOnBlur();
1811
- this._trigger('blur', event);
1808
+ if (document.activeElement && this.elContains(document.activeElement, true)) {
1809
+ return;
1812
1810
  }
1811
+
1812
+ this._delayBlurItemOnBlur();
1813
+ this._trigger('blur', event);
1813
1814
  });
1814
1815
  });
1815
1816
  }
@@ -4429,6 +4430,9 @@ class SelectBox {
4429
4430
  }
4430
4431
  }
4431
4432
  break;
4433
+
4434
+ case 'blur':
4435
+ this._handleOnBlur();
4432
4436
  }
4433
4437
  }
4434
4438
  });
@@ -4443,6 +4447,27 @@ class SelectBox {
4443
4447
  this._registerDropdownEvents();
4444
4448
  }
4445
4449
 
4450
+ _handleOnBlur() {
4451
+ const p = this._p;
4452
+
4453
+ setTimeout(() => {
4454
+ if (p.disabled) return;
4455
+
4456
+ this._trigger('search:blur');
4457
+
4458
+ if (this[DestroyedSymbol]) return; // destroyed by event handler
4459
+
4460
+ if (document.activeElement && (
4461
+ p.input && p.input.contains(document.activeElement) ||
4462
+ p.dropList && this.droplistElContains(document.activeElement, true))) {
4463
+ return;
4464
+ }
4465
+ if (p.throttledUpdateListItems)
4466
+ p.throttledUpdateListItems.cancel();
4467
+ this.closeList();
4468
+ });
4469
+ }
4470
+
4446
4471
  _unregisterDropdownEvents() {
4447
4472
  const p = this._p;
4448
4473
 
@@ -4612,18 +4637,7 @@ class SelectBox {
4612
4637
  avoidToggleFromClick = true;
4613
4638
  setTimeout(() => {avoidToggleFromClick = false;}, 10);
4614
4639
  }).
4615
- add(p.input, 'blur.dropdown', () => {
4616
- if (p.disabled) return;
4617
-
4618
- this._trigger('search:blur');
4619
-
4620
- if (this[DestroyedSymbol]) return; // destroyed by event handler
4621
-
4622
- if (p.throttledUpdateListItems)
4623
- p.throttledUpdateListItems.cancel();
4624
-
4625
- this.closeList();
4626
- });
4640
+ add(p.input, 'blur.dropdown', () => this._handleOnBlur());
4627
4641
  }
4628
4642
 
4629
4643
  p.sink.