ublo-lib 1.11.17 → 1.11.19
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.
|
@@ -56,14 +56,14 @@ const SearchBar = ({
|
|
|
56
56
|
const close = () => {
|
|
57
57
|
setText("");
|
|
58
58
|
};
|
|
59
|
-
const
|
|
59
|
+
const updateSearch = e => {
|
|
60
60
|
const userInput = e.currentTarget.value;
|
|
61
61
|
setText(userInput);
|
|
62
62
|
setState({
|
|
63
63
|
active: 0
|
|
64
64
|
});
|
|
65
65
|
};
|
|
66
|
-
const
|
|
66
|
+
const handleKeyDown = e => {
|
|
67
67
|
const allowedKeys = ["ArrowUp", "ArrowDown", "Enter", "Escape"];
|
|
68
68
|
const {
|
|
69
69
|
code,
|
|
@@ -104,6 +104,13 @@ const SearchBar = ({
|
|
|
104
104
|
container.scrollTop = newSelected.offsetTop - newSelected.clientHeight;
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
|
+
const handleBlur = () => {
|
|
108
|
+
if (text?.length > 2 && search?.result?.length === 0) {
|
|
109
|
+
Plausible.sendGoal("Search failed", {
|
|
110
|
+
Terms: text
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
};
|
|
107
114
|
const focusInput = () => {
|
|
108
115
|
input.current.focus();
|
|
109
116
|
};
|
|
@@ -135,13 +142,6 @@ const SearchBar = ({
|
|
|
135
142
|
window.removeEventListener("keydown", handleKeyPresses);
|
|
136
143
|
};
|
|
137
144
|
}, [autofocus, handleKeyPresses]);
|
|
138
|
-
React.useEffect(() => {
|
|
139
|
-
if (text?.length > 2 && search?.result?.length === 0) {
|
|
140
|
-
Plausible.sendGoal("Search failed", {
|
|
141
|
-
Terms: text
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}, [search?.result?.length, text]);
|
|
145
145
|
const Icon = search?.loading ? Icons.LoadIcon : Icons.SearchIcon;
|
|
146
146
|
const classes = classNames("search-bar", {
|
|
147
147
|
"search-bar--opened": search?.result,
|
|
@@ -158,10 +158,11 @@ const SearchBar = ({
|
|
|
158
158
|
ref: input,
|
|
159
159
|
type: "text",
|
|
160
160
|
value: text,
|
|
161
|
-
onChange:
|
|
162
|
-
onKeyDown:
|
|
161
|
+
onChange: updateSearch,
|
|
162
|
+
onKeyDown: handleKeyDown,
|
|
163
163
|
className: "search-bar__input",
|
|
164
|
-
placeholder: message(ubloLang, "what-are-you-looking-for", messages)
|
|
164
|
+
placeholder: message(ubloLang, "what-are-you-looking-for", messages),
|
|
165
|
+
onBlur: handleBlur
|
|
165
166
|
}), _jsx(Icon, {
|
|
166
167
|
className: "search-bar__icon"
|
|
167
168
|
}), _jsxs("div", {
|
|
@@ -5,7 +5,7 @@ const options = {
|
|
|
5
5
|
threshold: ratio(100),
|
|
6
6
|
};
|
|
7
7
|
export default function useInView(ref, cmsMode, selector, repeat = true, intersectionValue = 0.2) {
|
|
8
|
-
const { path } = useUbloContext();
|
|
8
|
+
const { lang, path } = useUbloContext();
|
|
9
9
|
const [compatible, setCompatible] = React.useState(false);
|
|
10
10
|
const callback = React.useCallback((entries) => {
|
|
11
11
|
entries.forEach((entry) => {
|
|
@@ -76,7 +76,7 @@ export default function useInView(ref, cmsMode, selector, repeat = true, interse
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
}, [callback, cmsMode, compatible, path, ref, selector]);
|
|
79
|
+
}, [callback, cmsMode, compatible, lang, path, ref, selector]);
|
|
80
80
|
}
|
|
81
81
|
function ratio(steps) {
|
|
82
82
|
return Array.from({ length: steps + 1 }).map((_, i) => i / steps);
|