X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/a6633642232efd164d4708967ab59e498fbff896..43749cd94e22682c78a0a7eab0a5865796624ec5:/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 0104eace7..fb74fa5b8 100644 --- a/resources/js/components/entity-selector-popup.js +++ b/resources/js/components/entity-selector-popup.js @@ -7,7 +7,9 @@ class EntitySelectorPopup { setup() { this.elem = this.$el; this.selectButton = this.$refs.select; + window.EntitySelectorPopup = this; + this.selectorEl = this.$refs.selector; this.callback = null; this.selection = null; @@ -20,12 +22,17 @@ class EntitySelectorPopup { show(callback) { this.callback = callback; this.elem.components.popup.show(); + 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); @@ -33,6 +40,7 @@ class EntitySelectorPopup { onSelectionConfirm(entity) { this.hide(); + this.getSelector().reset(); if (this.callback && entity) this.callback(entity); }