+ setEventItems (event: { items: QueryList<SuggestionComponent>, index?: number }) {
+ event.items.forEach(e => {
+ if (this.keyboardEventsManager.activeItem && this.keyboardEventsManager.activeItem === e) {
+ this.keyboardEventsManager.activeItem.active = true
+ } else {
+ e.active = false
+ }
+ })
+ }
+
+ initKeyboardEventsManager (event: { items: QueryList<SuggestionComponent>, index?: number }) {
+ if (this.keyboardEventsManager) this.keyboardEventsManager.change.unsubscribe()
+ this.keyboardEventsManager = new ListKeyManager(event.items)
+ if (event.index !== undefined) {
+ this.keyboardEventsManager.setActiveItem(event.index)
+ } else {
+ this.keyboardEventsManager.setFirstItemActive()
+ }
+ this.keyboardEventsManager.change.subscribe(
+ _ => this.setEventItems(event)
+ )