@danielgindi/selectbox 2.0.45 → 2.0.47

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.45
2
+ * @danielgindi/selectbox 2.0.47
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,21 @@ class DropList {
715
715
  return false;
716
716
  }
717
717
 
718
- if (!p.multi) {
718
+ if (p.multi) {
719
+ if (p.focusItemIndex >= 0) {
720
+ this.toggleFocusedItem();
721
+ event.preventDefault();
722
+ }
723
+ } else {
719
724
  this._setSingleSelectedItemEl(p.focusItemEl);
720
- }
721
725
 
722
- this._trigger('select', {
723
- value: item ? item.value : undefined,
724
- item: item[ItemSymbol] ?? item,
725
- event: event,
726
- el: p.focusItemEl,
727
- });
726
+ this._trigger('select', {
727
+ value: item ? item.value : undefined,
728
+ item: item[ItemSymbol] ?? item,
729
+ event: event,
730
+ el: p.focusItemEl,
731
+ });
732
+ }
728
733
 
729
734
  return true;
730
735
  }
@@ -2075,7 +2080,7 @@ class DropList {
2075
2080
  }
2076
2081
 
2077
2082
  hasFocusedItem() {
2078
- return this._p.focusItemIndex > -1;
2083
+ return this._p.focusItemIndex > -1 && this._p.focusItemIndex < this._p.items.length;
2079
2084
  }
2080
2085
 
2081
2086
  getFocusedItemIndex() {
@@ -3513,7 +3518,7 @@ Emits the following events:
3513
3518
  'search' {value}: input box value has changed
3514
3519
  'search:focus': input box has gained focus
3515
3520
  'search:blur': input box has lost focus
3516
- 'search:term': search term has been updated
3521
+ 'search:term': search term has been updated, before results were re-filtered
3517
3522
  'input:resize': input box resized
3518
3523
  'itemschanged' {term, mutated, count}: the current set of items has changed
3519
3524
  */
@@ -4028,8 +4033,8 @@ class SelectBox {
4028
4033
 
4029
4034
  if (performSearch) {
4030
4035
  p.filterTerm = p.input.value.trim();
4031
- p.dropList?.setSearchTerm(p.filterTerm, performSearch);
4032
4036
  this._trigger('search:term', p.filterTerm);
4037
+ p.dropList?.setSearchTerm(p.filterTerm, performSearch);
4033
4038
  }
4034
4039
 
4035
4040
  return this;
@@ -5590,8 +5595,8 @@ class SelectBox {
5590
5595
  if (p.disabled || p.readOnly) return;
5591
5596
 
5592
5597
  p.filterTerm = p.input.value.trim();
5593
- p.dropList?.setSearchTerm(p.filterTerm, true);
5594
5598
  this._trigger('search:term', p.filterTerm);
5599
+ p.dropList?.setSearchTerm(p.filterTerm, true);
5595
5600
  })
5596
5601
  .add(p.input, 'click.dropdown', () => {
5597
5602
  if (p.disabled || p.readOnly) return;
@@ -6434,8 +6439,8 @@ class SelectBox {
6434
6439
  p.input.value = value == null ? '' : String(value);
6435
6440
 
6436
6441
  p.filterTerm = '';
6437
- p.dropList?.setSearchTerm('', true);
6438
6442
  this._trigger('search:term', p.filterTerm);
6443
+ p.dropList?.setSearchTerm('', true);
6439
6444
  }
6440
6445
 
6441
6446
  /**