@danielgindi/selectbox 1.0.79 → 1.0.81
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 +24 -44
- package/dist/lib.cjs.js.map +1 -1
- package/dist/lib.cjs.min.js +2 -2
- package/dist/lib.cjs.min.js.map +1 -1
- package/dist/lib.es6.js +24 -44
- package/dist/lib.es6.js.map +1 -1
- package/dist/lib.es6.min.js +2 -2
- package/dist/lib.es6.min.js.map +1 -1
- package/dist/lib.umd.js +24 -44
- package/dist/lib.umd.js.map +1 -1
- package/dist/lib.umd.min.js +2 -2
- package/dist/lib.umd.min.js.map +1 -1
- package/lib/DropList.js +0 -1
- package/lib/SelectBox.js +23 -42
- package/package.json +1 -1
package/lib/DropList.js
CHANGED
package/lib/SelectBox.js
CHANGED
|
@@ -1917,9 +1917,7 @@ class SelectBox {
|
|
|
1917
1917
|
if (!dropList) return;
|
|
1918
1918
|
|
|
1919
1919
|
let avoidToggleFromClick = false,
|
|
1920
|
-
currentTouchId = null
|
|
1921
|
-
suppressKeyPress = false,
|
|
1922
|
-
suppressKeyPressRepeat = false;
|
|
1920
|
+
currentTouchId = null;
|
|
1923
1921
|
|
|
1924
1922
|
const keyEventsTarget = p.multi || p.searchable ? p.input : p.el;
|
|
1925
1923
|
|
|
@@ -1928,8 +1926,10 @@ class SelectBox {
|
|
|
1928
1926
|
if ((/**@type HTMLInputElement*/evt.currentTarget).readOnly)
|
|
1929
1927
|
return;
|
|
1930
1928
|
|
|
1931
|
-
|
|
1932
|
-
|
|
1929
|
+
let suppressEnterSpaceToggle = false;
|
|
1930
|
+
let lastKeyAllowsNonTypeKeys = p.lastKeyAllowsNonTypeKeys;
|
|
1931
|
+
p.lastKeyAllowsNonTypeKeys = false;
|
|
1932
|
+
let hasInputText = p.input && p.input.value.length > 0;
|
|
1933
1933
|
|
|
1934
1934
|
switch (evt.key) {
|
|
1935
1935
|
case VALUE_PAGE_UP:
|
|
@@ -1939,14 +1939,13 @@ class SelectBox {
|
|
|
1939
1939
|
case VALUE_HOME:
|
|
1940
1940
|
case VALUE_END:
|
|
1941
1941
|
if ((evt.key === VALUE_HOME || evt.key === VALUE_END) &&
|
|
1942
|
-
|
|
1942
|
+
hasInputText && !lastKeyAllowsNonTypeKeys) {
|
|
1943
1943
|
// Allow using HOME/END button within the textbox
|
|
1944
|
-
suppressKeyPressRepeat = true;
|
|
1945
1944
|
dropList._keydownFreeType(evt);
|
|
1946
1945
|
break;
|
|
1947
1946
|
}
|
|
1948
1947
|
|
|
1949
|
-
|
|
1948
|
+
p.lastKeyAllowsNonTypeKeys = true;
|
|
1950
1949
|
evt.preventDefault();
|
|
1951
1950
|
|
|
1952
1951
|
switch (evt.key) {
|
|
@@ -1984,10 +1983,11 @@ class SelectBox {
|
|
|
1984
1983
|
break;
|
|
1985
1984
|
|
|
1986
1985
|
case VALUE_SPACE:
|
|
1987
|
-
if (
|
|
1986
|
+
if (lastKeyAllowsNonTypeKeys) {
|
|
1987
|
+
p.lastKeyAllowsNonTypeKeys = true;
|
|
1988
|
+
|
|
1988
1989
|
if (dropList.isVisible() && dropList.hasFocusedItem()) {
|
|
1989
|
-
|
|
1990
|
-
suppressKeyPressRepeat = true;
|
|
1990
|
+
suppressEnterSpaceToggle = true;
|
|
1991
1991
|
if (p.multi)
|
|
1992
1992
|
dropList.toggleFocusedItem(evt);
|
|
1993
1993
|
else dropList.triggerItemSelection(evt);
|
|
@@ -1998,8 +1998,7 @@ class SelectBox {
|
|
|
1998
1998
|
|
|
1999
1999
|
case VALUE_ENTER:
|
|
2000
2000
|
if (dropList.isVisible() && dropList.hasFocusedItem()) {
|
|
2001
|
-
|
|
2002
|
-
suppressKeyPressRepeat = true;
|
|
2001
|
+
suppressEnterSpaceToggle = true;
|
|
2003
2002
|
evt.preventDefault();
|
|
2004
2003
|
dropList.triggerItemSelection(evt);
|
|
2005
2004
|
}
|
|
@@ -2020,39 +2019,21 @@ class SelectBox {
|
|
|
2020
2019
|
break;
|
|
2021
2020
|
|
|
2022
2021
|
default:
|
|
2023
|
-
suppressKeyPressRepeat = true;
|
|
2024
2022
|
dropList._keydownFreeType(evt);
|
|
2025
2023
|
break;
|
|
2026
2024
|
}
|
|
2027
2025
|
|
|
2028
|
-
|
|
2029
|
-
evt.key ===
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
evt.preventDefault();
|
|
2040
|
-
return;
|
|
2041
|
-
}
|
|
2042
|
-
|
|
2043
|
-
if (suppressKeyPressRepeat)
|
|
2044
|
-
return;
|
|
2045
|
-
|
|
2046
|
-
if (evt.key === VALUE_ENTER || (
|
|
2047
|
-
evt.key === VALUE_SPACE &&
|
|
2048
|
-
p.lastKeyAllowsNonTypeKeys &&
|
|
2049
|
-
!p.multi &&
|
|
2050
|
-
!dropList.hasFocusedItem()
|
|
2051
|
-
)
|
|
2052
|
-
) {
|
|
2053
|
-
this.toggleList();
|
|
2054
|
-
evt.preventDefault();
|
|
2055
|
-
evt.stopPropagation();
|
|
2026
|
+
if (!suppressEnterSpaceToggle) {
|
|
2027
|
+
if (evt.key === VALUE_ENTER || (
|
|
2028
|
+
evt.key === VALUE_SPACE &&
|
|
2029
|
+
p.lastKeyAllowsNonTypeKeys &&
|
|
2030
|
+
!p.multi &&
|
|
2031
|
+
!dropList.hasFocusedItem()
|
|
2032
|
+
)) {
|
|
2033
|
+
this.toggleList();
|
|
2034
|
+
evt.preventDefault();
|
|
2035
|
+
evt.stopPropagation();
|
|
2036
|
+
}
|
|
2056
2037
|
}
|
|
2057
2038
|
});
|
|
2058
2039
|
|
package/package.json
CHANGED