@danielgindi/selectbox 2.0.4 → 2.0.6

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 2.0.4
2
+ * @danielgindi/selectbox 2.0.6
3
3
  * git://github.com/danielgindi/selectbox.git
4
4
  */
5
5
  'use strict';
@@ -1216,11 +1216,10 @@ class DropList {
1216
1216
  if (!Array.isArray(filteredItems)) {
1217
1217
  if (term) {
1218
1218
  const matcher = new RegExp(escapeRegex(term), 'i');
1219
- const labelProp = p.labelProp;
1220
1219
 
1221
1220
  filteredItems = p.items.filter((x) => {
1222
1221
  if (!filterGroups && x._group) return true;
1223
- return matcher.test(x[labelProp]);
1222
+ return matcher.test(x.label);
1224
1223
  });
1225
1224
  } else {
1226
1225
  filteredItems = null;
@@ -1494,6 +1493,8 @@ class DropList {
1494
1493
 
1495
1494
  // Calculate virtual viewport size
1496
1495
  if (p.virtualListHelper.isVirtual()) {
1496
+ // Avoid extremely high size which will cause laying out the whole list
1497
+ menuEl.style.height = Math.min(el.clientHeight, document.body.clientHeight) + 'px';
1497
1498
  p.virtualListHelper.render();
1498
1499
  }
1499
1500
 
@@ -3655,7 +3656,6 @@ class SelectBox {
3655
3656
  p.resizeObserver.observe(p.el);
3656
3657
  }
3657
3658
 
3658
- if (o.filterFn)
3659
3659
  this.setFilterFn(o.filterFn);
3660
3660
 
3661
3661
  this.setItems(o.items);
@@ -4449,6 +4449,10 @@ class SelectBox {
4449
4449
  const p = this._p;
4450
4450
  if (p.filterFn === fn)
4451
4451
  return this;
4452
+
4453
+ // Do not keep this reference, as far as the user is concerned - he/she did not set a custom filter.
4454
+ p.filterFn = fn;
4455
+
4452
4456
  if (!fn) {
4453
4457
  // Add search by multi-item label
4454
4458
  fn = (items, term) => {
@@ -4462,7 +4466,8 @@ class SelectBox {
4462
4466
  });
4463
4467
  };
4464
4468
  }
4465
- p.filterFn = fn;
4469
+
4470
+ p.actualFilterFn = fn;
4466
4471
  p.dropList?.setFilterFn(fn);
4467
4472
  return this;
4468
4473
  }
@@ -5066,8 +5071,8 @@ class SelectBox {
5066
5071
  filterThrottleWindow: p.filterThrottleWindow,
5067
5072
  filterOnEmptyTerm: p.filterOnEmptyTerm,
5068
5073
  filterGroups: p.treatGroupSelectionAsItems,
5069
- filterEmptyGroups: p.treatGroupSelectionAsItems,
5070
- filterFn: p.filterFn,
5074
+ filterEmptyGroups: !p.treatGroupSelectionAsItems,
5075
+ filterFn: p.actualFilterFn,
5071
5076
 
5072
5077
  positionOptionsProvider: () => this._getDropListPositionOptions(),
5073
5078