X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/dba506a20e85efb028219c505e5017537f5234b3..c1d1ec5b89de4a0d758f7d2e429c804890346e76:/resources/js/components/entity-selector-popup.js diff --git a/resources/js/components/entity-selector-popup.js b/resources/js/components/entity-selector-popup.js index 231f1021f..fb74fa5b8 100644 --- a/resources/js/components/entity-selector-popup.js +++ b/resources/js/components/entity-selector-popup.js @@ -7,9 +7,9 @@ class EntitySelectorPopup { setup() { this.elem = this.$el; this.selectButton = this.$refs.select; - this.searchInput = this.$refs.searchInput; window.EntitySelectorPopup = this; + this.selectorEl = this.$refs.selector; this.callback = null; this.selection = null; @@ -22,13 +22,17 @@ class EntitySelectorPopup { show(callback) { this.callback = callback; this.elem.components.popup.show(); - this.searchInput.focus(); + this.getSelector().focusSearch(); } hide() { this.elem.components.popup.hide(); } + getSelector() { + return this.selectorEl.components['entity-selector']; + } + onSelectButtonClick() { this.hide(); if (this.selection !== null && this.callback) this.callback(this.selection); @@ -36,6 +40,7 @@ class EntitySelectorPopup { onSelectionConfirm(entity) { this.hide(); + this.getSelector().reset(); if (this.callback && entity) this.callback(entity); }