]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/entity-selector-popup.js
Merge branch 'development' of github.com:BookStackApp/BookStack into development
[bookstack] / resources / js / components / entity-selector-popup.js
index 0104eace7065373983792a525c501746616bc2c9..fb74fa5b829c8c14d625e335042e6e1d8e48df17 100644 (file)
@@ -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);
     }