@danielgindi/selectbox 1.0.80 → 1.0.83

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/SelectBox.js CHANGED
@@ -1899,6 +1899,13 @@ class SelectBox {
1899
1899
  },
1900
1900
  });
1901
1901
 
1902
+ p.sink.add(dropList.el, 'mousedown', (event) => {
1903
+ const li = closestUntil(event.target, 'li', event.currentTarget);
1904
+ if (!li) return;
1905
+
1906
+ event.preventDefault();
1907
+ });
1908
+
1902
1909
  this._registerDropdownEvents();
1903
1910
  }
1904
1911
 
@@ -1927,6 +1934,9 @@ class SelectBox {
1927
1934
  return;
1928
1935
 
1929
1936
  let suppressEnterSpaceToggle = false;
1937
+ let lastKeyAllowsNonTypeKeys = p.lastKeyAllowsNonTypeKeys;
1938
+ p.lastKeyAllowsNonTypeKeys = false;
1939
+ let hasInputText = p.input && p.input.value.length > 0;
1930
1940
 
1931
1941
  switch (evt.key) {
1932
1942
  case VALUE_PAGE_UP:
@@ -1936,12 +1946,13 @@ class SelectBox {
1936
1946
  case VALUE_HOME:
1937
1947
  case VALUE_END:
1938
1948
  if ((evt.key === VALUE_HOME || evt.key === VALUE_END) &&
1939
- p.input && p.input.value.length > 0 && !p.lastKeyAllowsNonTypeKeys) {
1949
+ hasInputText && !lastKeyAllowsNonTypeKeys) {
1940
1950
  // Allow using HOME/END button within the textbox
1941
1951
  dropList._keydownFreeType(evt);
1942
1952
  break;
1943
1953
  }
1944
1954
 
1955
+ p.lastKeyAllowsNonTypeKeys = true;
1945
1956
  evt.preventDefault();
1946
1957
 
1947
1958
  switch (evt.key) {
@@ -1979,7 +1990,9 @@ class SelectBox {
1979
1990
  break;
1980
1991
 
1981
1992
  case VALUE_SPACE:
1982
- if (p.lastKeyAllowsNonTypeKeys) {
1993
+ if (lastKeyAllowsNonTypeKeys) {
1994
+ p.lastKeyAllowsNonTypeKeys = true;
1995
+
1983
1996
  if (dropList.isVisible() && dropList.hasFocusedItem()) {
1984
1997
  suppressEnterSpaceToggle = true;
1985
1998
  if (p.multi)
@@ -2017,14 +2030,6 @@ class SelectBox {
2017
2030
  break;
2018
2031
  }
2019
2032
 
2020
- p.lastKeyAllowsNonTypeKeys = evt.key === VALUE_UP ||
2021
- evt.key === VALUE_DOWN ||
2022
- evt.key === VALUE_PAGE_UP ||
2023
- evt.key === VALUE_PAGE_DOWN ||
2024
- evt.key === VALUE_HOME ||
2025
- evt.key === VALUE_END ||
2026
- (evt.key === VALUE_SPACE && !!p.lastKeyAllowsNonTypeKeys);
2027
-
2028
2033
  if (!suppressEnterSpaceToggle) {
2029
2034
  if (evt.key === VALUE_ENTER || (
2030
2035
  evt.key === VALUE_SPACE &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielgindi/selectbox",
3
- "version": "1.0.80",
3
+ "version": "1.0.83",
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",