@danielgindi/selectbox 1.0.79 → 1.0.81

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.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @danielgindi/selectbox 1.0.79
2
+ * @danielgindi/selectbox 1.0.81
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  (function (global, factory) {
@@ -7786,7 +7786,6 @@
7786
7786
  var p = this._p;
7787
7787
 
7788
7788
  p.sink.add(p.el, 'keydown', function (evt) {return _this9._keydown(evt);});
7789
- p.sink.add(p.el, 'keypress', function (evt) {return _this9._keydown(evt);});
7790
7789
  } }, { key: "_keydown", value:
7791
7790
 
7792
7791
  function _keydown(event) {
@@ -11389,9 +11388,7 @@
11389
11388
  if (!dropList) return;
11390
11389
 
11391
11390
  var avoidToggleFromClick = false,
11392
- currentTouchId = null,
11393
- suppressKeyPress = false,
11394
- suppressKeyPressRepeat = false;
11391
+ currentTouchId = null;
11395
11392
 
11396
11393
  var keyEventsTarget = p.multi || p.searchable ? p.input : p.el;
11397
11394
 
@@ -11400,8 +11397,10 @@
11400
11397
  if ( /**@type HTMLInputElement*/evt.currentTarget.readOnly)
11401
11398
  return;
11402
11399
 
11403
- suppressKeyPress = false;
11404
- suppressKeyPressRepeat = false;
11400
+ var suppressEnterSpaceToggle = false;
11401
+ var lastKeyAllowsNonTypeKeys = p.lastKeyAllowsNonTypeKeys;
11402
+ p.lastKeyAllowsNonTypeKeys = false;
11403
+ var hasInputText = p.input && p.input.value.length > 0;
11405
11404
 
11406
11405
  switch (evt.key) {
11407
11406
  case keycodeJs.VALUE_PAGE_UP:
@@ -11411,14 +11410,13 @@
11411
11410
  case keycodeJs.VALUE_HOME:
11412
11411
  case keycodeJs.VALUE_END:
11413
11412
  if ((evt.key === keycodeJs.VALUE_HOME || evt.key === keycodeJs.VALUE_END) &&
11414
- p.input && p.input.value.length > 0 && !p.lastKeyAllowsNonTypeKeys) {
11413
+ hasInputText && !lastKeyAllowsNonTypeKeys) {
11415
11414
  // Allow using HOME/END button within the textbox
11416
- suppressKeyPressRepeat = true;
11417
11415
  dropList._keydownFreeType(evt);
11418
11416
  break;
11419
11417
  }
11420
11418
 
11421
- suppressKeyPress = true;
11419
+ p.lastKeyAllowsNonTypeKeys = true;
11422
11420
  evt.preventDefault();
11423
11421
 
11424
11422
  switch (evt.key) {
@@ -11456,10 +11454,11 @@
11456
11454
  break;
11457
11455
 
11458
11456
  case keycodeJs.VALUE_SPACE:
11459
- if (p.lastKeyAllowsNonTypeKeys) {
11457
+ if (lastKeyAllowsNonTypeKeys) {
11458
+ p.lastKeyAllowsNonTypeKeys = true;
11459
+
11460
11460
  if (dropList.isVisible() && dropList.hasFocusedItem()) {
11461
- suppressKeyPress = true;
11462
- suppressKeyPressRepeat = true;
11461
+ suppressEnterSpaceToggle = true;
11463
11462
  if (p.multi)
11464
11463
  dropList.toggleFocusedItem(evt);else
11465
11464
  dropList.triggerItemSelection(evt);
@@ -11470,8 +11469,7 @@
11470
11469
 
11471
11470
  case keycodeJs.VALUE_ENTER:
11472
11471
  if (dropList.isVisible() && dropList.hasFocusedItem()) {
11473
- suppressKeyPress = true;
11474
- suppressKeyPressRepeat = true;
11472
+ suppressEnterSpaceToggle = true;
11475
11473
  evt.preventDefault();
11476
11474
  dropList.triggerItemSelection(evt);
11477
11475
  }
@@ -11492,39 +11490,21 @@
11492
11490
  break;
11493
11491
 
11494
11492
  default:
11495
- suppressKeyPressRepeat = true;
11496
11493
  dropList._keydownFreeType(evt);
11497
11494
  break;}
11498
11495
 
11499
11496
 
11500
- p.lastKeyAllowsNonTypeKeys = evt.key === keycodeJs.VALUE_UP ||
11501
- evt.key === keycodeJs.VALUE_DOWN ||
11502
- evt.key === keycodeJs.VALUE_PAGE_UP ||
11503
- evt.key === keycodeJs.VALUE_PAGE_DOWN ||
11504
- evt.key === keycodeJs.VALUE_HOME ||
11505
- evt.key === keycodeJs.VALUE_END ||
11506
- evt.key === keycodeJs.VALUE_SPACE && !!p.lastKeyAllowsNonTypeKeys;
11507
- }).
11508
- add(keyEventsTarget, 'keypress.dropdown', function (evt) {
11509
- if (suppressKeyPress) {
11510
- suppressKeyPress = false;
11511
- evt.preventDefault();
11512
- return;
11513
- }
11514
-
11515
- if (suppressKeyPressRepeat)
11516
- return;
11517
-
11518
- if (evt.key === keycodeJs.VALUE_ENTER ||
11519
- evt.key === keycodeJs.VALUE_SPACE &&
11520
- p.lastKeyAllowsNonTypeKeys &&
11521
- !p.multi &&
11522
- !dropList.hasFocusedItem())
11523
-
11524
- {
11525
- _this6.toggleList();
11526
- evt.preventDefault();
11527
- evt.stopPropagation();
11497
+ if (!suppressEnterSpaceToggle) {
11498
+ if (evt.key === keycodeJs.VALUE_ENTER ||
11499
+ evt.key === keycodeJs.VALUE_SPACE &&
11500
+ p.lastKeyAllowsNonTypeKeys &&
11501
+ !p.multi &&
11502
+ !dropList.hasFocusedItem())
11503
+ {
11504
+ _this6.toggleList();
11505
+ evt.preventDefault();
11506
+ evt.stopPropagation();
11507
+ }
11528
11508
  }
11529
11509
  });
11530
11510