Skip to content

Commit 602cbef

Browse files
author
Daniel Morse
committed
fix: make sure autosuggest event listeners are re-added when component re-connects
1 parent a8e210d commit 602cbef

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

packages/components/bolt-typeahead/typeahead.autosuggest.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ class BoltAutosuggest extends withPreact() {
108108
super.disconnecting && super.disconnecting();
109109
// Keep an object of listener types mapped to callback functions
110110
this._listeners = {};
111+
112+
// hack so that "ready" event will fire next time component connects,
113+
// and any external listeners will be re-added
114+
this._wasInitiallyRendered = false;
111115
}
112116

113117
// return the parent that's rendering <bolt-autosuggest> based on Shadow DOM usage

packages/components/bolt-typeahead/typeahead.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ class BoltTypeahead extends withEvents(withLitHtml()) {
159159

160160
if (this.autosuggest._wasInitiallyRendered) {
161161
setupEventHandlers();
162-
} else {
163-
this.autosuggest.addEventListener('ready', () => {
164-
setupEventHandlers();
165-
});
166162
}
163+
164+
this.autosuggest.addEventListener('ready', () => {
165+
setupEventHandlers();
166+
});
167167
}
168168
}
169169
}

0 commit comments

Comments
 (0)