@danielgindi/selectbox 2.0.2 → 2.0.4

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/lib/DropList.js CHANGED
@@ -652,7 +652,8 @@ class DropList {
652
652
  const p = this._p;
653
653
 
654
654
  if (this.hasFocusedItem() && p.multi) {
655
- let item = p.items[p.focusItemIndex];
655
+ const items = p.filteredItems ?? p.items;
656
+ let item = items[p.focusItemIndex];
656
657
  if (item._nocheck || item._nointeraction) return this;
657
658
 
658
659
  item._checked = !item._checked;
@@ -720,7 +721,7 @@ class DropList {
720
721
  const p = this._p, labelProp = p.labelProp, valueProp = p.valueProp;
721
722
 
722
723
  let isMulti = p.multi;
723
- let items = p.items;
724
+ const items = p.items;
724
725
 
725
726
  if (atIndex == null || atIndex < 0 || atIndex >= p.items.length) {
726
727
  atIndex = -1;
@@ -1230,7 +1231,7 @@ class DropList {
1230
1231
  p.filteredItems = null;
1231
1232
  }
1232
1233
 
1233
- this.needsRefilter = false;
1234
+ p.needsRefilter = false;
1234
1235
 
1235
1236
  const items = p.filteredItems ?? p.items;
1236
1237
  p.hasNoResultsItem = items.length === 0 && !!p.noResultsText;
@@ -1251,11 +1252,17 @@ class DropList {
1251
1252
  return this;
1252
1253
  }
1253
1254
 
1254
- getFilteredItemCount() {
1255
+ rushRefilter() {
1255
1256
  const p = this._p;
1256
-
1257
1257
  if (p.needsRefilter)
1258
1258
  this._refilterItems();
1259
+ return this;
1260
+ }
1261
+
1262
+ getFilteredItemCount() {
1263
+ const p = this._p;
1264
+
1265
+ this.rushRefilter();
1259
1266
 
1260
1267
  if (p.filteredItems)
1261
1268
  return p.filteredItems.length;
@@ -1701,6 +1708,8 @@ class DropList {
1701
1708
  setCheckedValues(values) {
1702
1709
  const p = this._p;
1703
1710
 
1711
+ this.rushRefilter();
1712
+
1704
1713
  let groupIndexes = [];
1705
1714
 
1706
1715
  for (let i = 0, count = p.items.length; i < count; i++) {
@@ -1764,7 +1773,7 @@ class DropList {
1764
1773
 
1765
1774
  excludeGroups = excludeGroups && p.groupCount > 0;
1766
1775
 
1767
- let items = [];
1776
+ const items = [];
1768
1777
 
1769
1778
  for (let i = 0, count = p.items.length; i < count; i++) {
1770
1779
  let item = p.items[i];
@@ -1805,9 +1814,7 @@ class DropList {
1805
1814
  }
1806
1815
  });
1807
1816
 
1808
- if (p.needsRefilter) {
1809
- this._refilterItems();
1810
- }
1817
+ this.rushRefilter();
1811
1818
 
1812
1819
  const el = p.el;
1813
1820
  el.style.position = 'absolute';
@@ -2015,6 +2022,8 @@ class DropList {
2015
2022
  setFocusedItemAtIndex(itemIndex) {
2016
2023
  const p = this._p;
2017
2024
 
2025
+ this.rushRefilter();
2026
+
2018
2027
  if (p.filteredItems) {
2019
2028
  const item = p.items[itemIndex];
2020
2029
  itemIndex = p.items.indexOf(item);
@@ -2212,6 +2221,8 @@ class DropList {
2212
2221
  setSingleSelectedItemAtIndex(itemIndex) {
2213
2222
  const p = this._p;
2214
2223
 
2224
+ this.rushRefilter();
2225
+
2215
2226
  let itemEl = null;
2216
2227
 
2217
2228
  if (itemIndex > -1 && !p.items[itemIndex]._nointeraction) {
@@ -2971,7 +2982,7 @@ class DropList {
2971
2982
  let affectedItems = 0;
2972
2983
 
2973
2984
  if (p.autoCheckGroupChildren) {
2974
- let items = p.filteredItems ?? p.items;
2985
+ const items = p.filteredItems ?? p.items;
2975
2986
  let groupIndex = items.indexOf(item);
2976
2987
 
2977
2988
  for (let i = groupIndex + 1, len = items.length; i < len; i++) {
@@ -3014,7 +3025,7 @@ class DropList {
3014
3025
  affectedItems: affectedItems,
3015
3026
  });
3016
3027
  } else if (p.groupCount > 0 && p.autoCheckGroupChildren) {
3017
- let items = p.filteredItems ?? p.items;
3028
+ const items = p.filteredItems ?? p.items;
3018
3029
  let itemIndex = items.indexOf(item);
3019
3030
  let groupIndex = -1;
3020
3031
 
@@ -3040,7 +3051,7 @@ class DropList {
3040
3051
  if (!(p.multi && p.autoCheckGroupChildren && groupIndex > -1))
3041
3052
  return this;
3042
3053
 
3043
- let items = p.filteredItems ?? p.items;
3054
+ const items = p.filteredItems ?? p.items;
3044
3055
  let groupItem = items[groupIndex];
3045
3056
 
3046
3057
  if (!groupItem || !groupItem._group) return this;
@@ -3166,7 +3177,7 @@ class DropList {
3166
3177
  _determineVirtualMode(targetItemCount) {
3167
3178
  const p = this._p;
3168
3179
 
3169
- let items = p.filteredItems ?? p.items;
3180
+ const items = p.filteredItems ?? p.items;
3170
3181
  if (targetItemCount === undefined) {
3171
3182
  targetItemCount = items.length;
3172
3183
  }
package/lib/SelectBox.js CHANGED
@@ -2306,6 +2306,7 @@ class SelectBox {
2306
2306
  p.splitListCheckedGroups);
2307
2307
  }
2308
2308
  dropList.setItems(items);
2309
+ dropList.invokeRefilter();
2309
2310
  p.itemsChanged = false;
2310
2311
  p.selectionChanged = true;
2311
2312
  p.resortBySelectionNeeded = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielgindi/selectbox",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "A collection of dom utilities. So you can work natively with the dom without dom frameworks.",
5
5
  "main": "dist/lib.cjs.min.js",
6
6
  "module": "lib/index.js",
@@ -35,6 +35,7 @@
35
35
  }
36
36
 
37
37
  ul {
38
+ position: relative;
38
39
  list-style: none;
39
40
  margin: 0;
40
41
  padding: 0;