Fixed editor JavaScript error in TemplateManager

- Caused when loading the editor with no templates in the system.
- Tried to init a search box that did not exist.
This commit is contained in:
Dan Brown 2020-04-04 00:09:58 +01:00
parent c1fe068ffc
commit ef416d3e86
No known key found for this signature in database
GPG key ID: 46D9F943C24A2EF9

View file

@ -56,6 +56,10 @@ class TemplateManager {
setupSearchBox() {
const searchBox = this.elem.querySelector('.search-box');
// Search box may not exist if there are no existing templates in the system.
if (!searchBox) return;
const input = searchBox.querySelector('input');
const submitButton = searchBox.querySelector('button');
const cancelButton = searchBox.querySelector('button.search-box-cancel');
@ -70,7 +74,7 @@ class TemplateManager {
}
performSearch = performSearch.bind(this);
// Searchbox enter press
// Search box enter press
searchBox.addEventListener('keypress', event => {
if (event.key === 'Enter') {
event.preventDefault();