@adamjanicki/ui-extended 1.0.2 → 1.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/components/Autocomplete.js +12 -3
- package/package.json +1 -1
|
@@ -64,7 +64,7 @@ var Autocomplete = function (props) {
|
|
|
64
64
|
onSelect(v);
|
|
65
65
|
var current = inputRef.current;
|
|
66
66
|
closeMenu();
|
|
67
|
-
if (focusOnSelect)
|
|
67
|
+
if (!focusOnSelect)
|
|
68
68
|
return current === null || current === void 0 ? void 0 : current.focus();
|
|
69
69
|
};
|
|
70
70
|
var closeMenu = function () {
|
|
@@ -75,6 +75,7 @@ var Autocomplete = function (props) {
|
|
|
75
75
|
setOpen(true);
|
|
76
76
|
};
|
|
77
77
|
var handleKeys = function (_a) {
|
|
78
|
+
var _b, _c;
|
|
78
79
|
var code = _a.code;
|
|
79
80
|
if (code === "Escape") {
|
|
80
81
|
closeMenu();
|
|
@@ -83,10 +84,18 @@ var Autocomplete = function (props) {
|
|
|
83
84
|
if (code === "Enter") {
|
|
84
85
|
var current = onRef.current;
|
|
85
86
|
if (modulo > 0 && current) {
|
|
87
|
+
// Horrible heuristic to handle links
|
|
88
|
+
// It's terrible, but efficient
|
|
89
|
+
var child = current.firstChild;
|
|
90
|
+
if (child && child.nodeName === "A")
|
|
91
|
+
(_b = child.click) === null || _b === void 0 ? void 0 : _b.call(child);
|
|
86
92
|
return current.click();
|
|
87
93
|
}
|
|
88
|
-
else {
|
|
89
|
-
onUnselectedEnter
|
|
94
|
+
else if (onUnselectedEnter) {
|
|
95
|
+
onUnselectedEnter();
|
|
96
|
+
closeMenu();
|
|
97
|
+
if (!focusOnSelect)
|
|
98
|
+
return (_c = inputRef.current) === null || _c === void 0 ? void 0 : _c.blur();
|
|
90
99
|
}
|
|
91
100
|
}
|
|
92
101
|
if (modulo > 0 && code === "ArrowDown") {
|