diff --git a/client/core/src/drop-down/drop-down.html b/client/core/src/drop-down/drop-down.html index 04cdffc75..c8971a551 100644 --- a/client/core/src/drop-down/drop-down.html +++ b/client/core/src/drop-down/drop-down.html @@ -1,4 +1,4 @@ - + diff --git a/client/core/src/drop-down/drop-down.js b/client/core/src/drop-down/drop-down.js index e8227858a..ac99fe7d2 100644 --- a/client/core/src/drop-down/drop-down.js +++ b/client/core/src/drop-down/drop-down.js @@ -7,13 +7,16 @@ export default class DropDown { this.$filter = $filter; this.$timeout = $timeout; - this.container = $element[0].querySelector('ul.dropdown'); this._search = null; this.itemsFiltered = []; this._activeOption = -1; this._focusingFilter = false; this._tryToShow = 0; } + + get container() { + return this.$element[0].querySelector('ul.dropdown'); + } get show() { return this._show; } @@ -70,12 +73,15 @@ export default class DropDown { _setFocusInFilterInput(value, oldValue) { if (value && !this._focusingFilter && oldValue !== value && this.filter) { - let inputFilterSearch = this.$element[0].querySelector('input'); - this._focusingFilter = true; this.$timeout(() => { - inputFilterSearch.focus(); - this._focusingFilter = false; - }, 250); + let inputFilterSearch = this.$element[0].querySelector('input'); + this._focusingFilter = true; + if (inputFilterSearch) + this.$timeout(() => { + inputFilterSearch.focus(); + this._focusingFilter = false; + }, 250); + }); } } _background(create) { @@ -184,10 +190,12 @@ export default class DropDown { } setScrollPosition() { let child = this.$element[0].querySelector('ul.dropdown li.active'); - let childRect = child.getBoundingClientRect(); - let containerRect = this.container.getBoundingClientRect(); - if (typeof child.scrollIntoView === 'function' && (childRect.top > containerRect.top + containerRect.height || childRect.top < containerRect.top)) { - child.scrollIntoView(); + if (child) { + let childRect = child.getBoundingClientRect(); + let containerRect = this.container.getBoundingClientRect(); + if (typeof child.scrollIntoView === 'function' && (childRect.top > containerRect.top + containerRect.height || childRect.top < containerRect.top)) { + child.scrollIntoView(); + } } } selectItem(item) {