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() {
initPersistentUserCallouts();
initDefaultTrackers();
document.querySelector('#search').addEventListener(
'focus',
() => {
import(/* webpackChunkName: 'globalSearch' */ './search_autocomplete')
.then(({ default: initSearchAutocomplete }) => {
const searchDropdown = initSearchAutocomplete();
searchDropdown.onSearchInputFocus();
})
.catch(() => {});
},
{ once: true },
);
const search = document.querySelector('#search');
if (search) {
search.addEventListener(
'focus',
() => {
import(/* webpackChunkName: 'globalSearch' */ './search_autocomplete')
.then(({ default: initSearchAutocomplete }) => {
const searchDropdown = initSearchAutocomplete();
searchDropdown.onSearchInputFocus();
})
.catch(() => {});
},
{ once: true },
);
}
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