ublo-lib 1.47.20 → 1.47.22
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.
|
@@ -15,7 +15,7 @@ const { publicRuntimeConfig } = getConfig();
|
|
|
15
15
|
const { ubloApi, site } = publicRuntimeConfig;
|
|
16
16
|
const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messages, seo, exclude, autofocus, additionalResults = [], }) => {
|
|
17
17
|
const input = React.useRef();
|
|
18
|
-
const
|
|
18
|
+
const resultsContainer = React.useRef();
|
|
19
19
|
const [state, setState] = React.useState({ active: 0, selected: undefined });
|
|
20
20
|
const { lang: ubloLang = lang } = useUbloContext();
|
|
21
21
|
const { text, setText, search } = useSearch({
|
|
@@ -55,7 +55,7 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
|
|
|
55
55
|
close();
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
const container =
|
|
58
|
+
const container = resultsContainer.current;
|
|
59
59
|
const firstResult = container?.querySelector(".search-bar__result");
|
|
60
60
|
const allResults = Array.from(container?.querySelectorAll(".search-bar__result"));
|
|
61
61
|
const lastResult = allResults[allResults.length - 1];
|
|
@@ -119,8 +119,8 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
|
|
|
119
119
|
}, [autofocus, handleKeyPresses]);
|
|
120
120
|
const Icon = search?.loading ? Icons.LoadIcon : Icons.SearchIcon;
|
|
121
121
|
const matchingAdditionalResults = additionalResults.filter((result) => {
|
|
122
|
-
const normalizedResult = result.
|
|
123
|
-
const normalizedText = text.toLowerCase();
|
|
122
|
+
const normalizedResult = normalize(result.title.toLowerCase());
|
|
123
|
+
const normalizedText = normalize(text.toLowerCase());
|
|
124
124
|
return normalizedResult.includes(normalizedText);
|
|
125
125
|
});
|
|
126
126
|
const results = [...(search?.result || []), ...matchingAdditionalResults];
|
|
@@ -128,7 +128,7 @@ const SearchBar = ({ lang, resultFormatter, backdrop, OverrideIcons = {}, messag
|
|
|
128
128
|
"search-bar--opened": results.length > 0,
|
|
129
129
|
"search-bar--loading": search?.loading,
|
|
130
130
|
});
|
|
131
|
-
return (_jsxs("div", { className: classes, children: [backdrop && _jsx("div", { className: "search-bar__backdrop", onClick: close }), _jsxs("div", { className: "search-bar__input-container", children: [_jsx("input", { ref: input, type: "text", value: text, onChange: updateSearch, onKeyDown: handleKeyDown, className: "search-bar__input", placeholder: message(ubloLang, "what-are-you-looking-for", messages), onBlur: handleBlur }), _jsx(Icon, { className: "search-bar__icon" }), _jsxs("div", { ref:
|
|
131
|
+
return (_jsxs("div", { className: classes, children: [backdrop && _jsx("div", { className: "search-bar__backdrop", onClick: close }), _jsxs("div", { className: "search-bar__input-container", children: [_jsx("input", { ref: input, type: "text", value: text, onChange: updateSearch, onKeyDown: handleKeyDown, className: "search-bar__input", placeholder: message(ubloLang, "what-are-you-looking-for", messages), onBlur: handleBlur }), _jsx(Icon, { className: "search-bar__icon" }), _jsxs("div", { ref: resultsContainer, className: "search-bar__results", children: [results?.map((result, i) => {
|
|
132
132
|
const { name, title, page, path } = result;
|
|
133
133
|
const externalLink = page === undefined;
|
|
134
134
|
const Tag = externalLink ? "a" : Link;
|