Commit a24cb95f authored by Lukas Eipert's avatar Lukas Eipert

Safe guard search initialization

The search initialization errors on pages that don't have a search (e.g.
login, terms agreement page)
parent f628bfb9
...@@ -111,18 +111,21 @@ function deferredInitialisation() { ...@@ -111,18 +111,21 @@ function deferredInitialisation() {
initPersistentUserCallouts(); initPersistentUserCallouts();
initDefaultTrackers(); initDefaultTrackers();
document.querySelector('#search').addEventListener( const search = document.querySelector('#search');
'focus', if (search) {
() => { search.addEventListener(
import(/* webpackChunkName: 'globalSearch' */ './search_autocomplete') 'focus',
.then(({ default: initSearchAutocomplete }) => { () => {
const searchDropdown = initSearchAutocomplete(); import(/* webpackChunkName: 'globalSearch' */ './search_autocomplete')
searchDropdown.onSearchInputFocus(); .then(({ default: initSearchAutocomplete }) => {
}) const searchDropdown = initSearchAutocomplete();
.catch(() => {}); searchDropdown.onSearchInputFocus();
}, })
{ once: true }, .catch(() => {});
); },
{ once: true },
);
}
addSelectOnFocusBehaviour('.js-select-on-focus'); addSelectOnFocusBehaviour('.js-select-on-focus');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment