Browse Source

Bugfix: after first completer session, subsequent sessions do not populate common subset on starting.

Afshin Darian 8 years ago
parent
commit
057018b11b
1 changed files with 13 additions and 4 deletions
  1. 13 4
      src/completer/widget.ts

+ 13 - 4
src/completer/widget.ts

@@ -155,9 +155,7 @@ class CompleterWidget extends Widget {
    * Reset the widget.
    */
   reset(): void {
-    this._activeIndex = 0;
-    this._anchorPoint = 0;
-    this._firstLoad = true;
+    this._reset();
     if (this._model) {
       this._model.reset();
     }
@@ -234,6 +232,7 @@ class CompleterWidget extends Widget {
 
     // If there are no items, reset and bail.
     if (!items || !items.length) {
+      this._reset();
       this.hide();
       this.visibilityChanged.emit(void 0);
       return;
@@ -405,6 +404,15 @@ class CompleterWidget extends Widget {
     return false;
   }
 
+  /**
+   * Reset the internal flags to defaults.
+   */
+  private _reset(): void {
+    this._activeIndex = 0;
+    this._anchorPoint = 0;
+    this._firstLoad = true;
+  }
+
   /**
    * Set the visible dimensions of the widget.
    */
@@ -457,9 +465,10 @@ class CompleterWidget extends Widget {
   private _selectActive(): void {
     let active = this.node.querySelector(`.${ACTIVE_CLASS}`) as HTMLElement;
     if (!active) {
+      this._reset();
       return;
     }
-    this.selected.emit(active.dataset['value']);
+    this.selected.emit(active.getAttribute('data-value'));
     this.reset();
   }