@danielgindi/selectbox 2.0.36 → 2.0.38

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 2.0.36
2
+ * @danielgindi/selectbox 2.0.38
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  (function (global, factory) {
@@ -8962,14 +8962,14 @@
8962
8962
 
8963
8963
  // Inline search box not available, then support typing to focus by first letters
8964
8964
  if (!p.searchable)
8965
- this._keydownFreeType(event);
8965
+ this._keydownFreeType(event, !this.isVisible());
8966
8966
 
8967
8967
  preventDefault = false;
8968
8968
  }
8969
8969
  }
8970
8970
  }
8971
8971
 
8972
- _keydownFreeType(evt) {var _p$filteredItems13;
8972
+ _keydownFreeType(evt, autoSelect) {var _p$filteredItems13;
8973
8973
  const p = this._p;
8974
8974
 
8975
8975
  // noinspection JSDeprecatedSymbols
@@ -9028,7 +9028,7 @@
9028
9028
  let next = p.virtualListHelper.getItemElementAt(matchIndex);
9029
9029
  this._focus(evt, next || null, matchIndex, true);
9030
9030
 
9031
- if (!this.isVisible()) {
9031
+ if (autoSelect) {
9032
9032
  this.triggerItemSelection(next ? null : items[matchIndex], evt);
9033
9033
  }
9034
9034
 
@@ -9907,6 +9907,7 @@
9907
9907
  * @property {function(item: DropList.ItemBase, itemEl: Element):(*|false)} [renderRestMultiItem]
9908
9908
  * @property {function(item: DropList.ItemBase, itemEl: Element)} [unrenderRestMultiItem]
9909
9909
  * @property {boolean} [searchable=false] is it searchable?
9910
+ * @property {boolean} [allowTypeToSelect=true] default behavior of type to select (focus first item starting with the search term) when searchable is true
9910
9911
  * @property {string} [noResultsText='No matching results'] text for no results (empty for none)
9911
9912
  * @property {boolean} [autoSelectTextOnCheck=true] automatically select text in input when an item is checked (multi mode). Used to allow the user to quickly type multiple items.
9912
9913
  * @property {number} [filterThrottleWindow=300] throttle time (milliseconds) for filtering
@@ -10037,6 +10038,7 @@
10037
10038
  showPlaceholderInTooltip: o.showPlaceholderInTooltip,
10038
10039
  multiPlaceholderFormatter: o.multiPlaceholderFormatter,
10039
10040
  searchable: o.searchable,
10041
+ allowTypeToSelect: o.allowTypeToSelect,
10040
10042
  noResultsText: o.noResultsText,
10041
10043
  autoSelectTextOnCheck: o.autoSelectTextOnCheck,
10042
10044
 
@@ -10819,6 +10821,20 @@
10819
10821
  return this;
10820
10822
  }
10821
10823
 
10824
+ /**
10825
+ * @param {boolean} allowTypeToSelect
10826
+ * @returns {SelectBox}
10827
+ */
10828
+ setAllowTypeToSelect(allowTypeToSelect) {
10829
+ const p = this._p;
10830
+ allowTypeToSelect = !!allowTypeToSelect;
10831
+ if (p.allowTypeToSelect === allowTypeToSelect)
10832
+ return this;
10833
+
10834
+ p.allowTypeToSelect = allowTypeToSelect;
10835
+ return this;
10836
+ }
10837
+
10822
10838
  /**
10823
10839
  * @returns {boolean}
10824
10840
  */
@@ -12018,7 +12034,15 @@
12018
12034
  break;
12019
12035
 
12020
12036
  default:
12021
- dropList._keydownFreeType(evt);
12037
+ if (p.allowTypeToSelect) {
12038
+ dropList._keydownFreeType(evt, true);
12039
+ } else {
12040
+ this.openList();
12041
+ setTimeout(() => {
12042
+ if (this[DestroyedSymbol]) return; // destroyed by event handler
12043
+ dropList._keydownFreeType(evt, false);
12044
+ });
12045
+ }
12022
12046
  break;
12023
12047
  }
12024
12048