fix enter select

This commit is contained in:
jonaswinkler 2020-12-28 12:48:41 +01:00
parent 8af0259671
commit 7beb8a0929
2 changed files with 13 additions and 9 deletions

View File

@ -196,7 +196,9 @@ export class FilterableDropdownComponent {
setTimeout(() => {
this.listFilterTextInput.nativeElement.focus();
}, 0)
this.selectionModel.reset()
if (this.editing) {
this.selectionModel.reset()
}
this.open.next()
} else {
this.filterText = ''
@ -204,12 +206,14 @@ export class FilterableDropdownComponent {
}
listFilterEnter(): void {
// let filtered = this.filterPipe.transform(this.toggleableItems, this.filterText)
// if (filtered.length == 1) {
// let toggleableItem = this.toggleableItems.find(ti => ti.item.id == filtered[0].item.id)
// if (toggleableItem) toggleableItem.state = ToggleableItemState.Selected
// this.toggleItem(filtered[0])
// this.dropdown.close()
// }
let filtered = this.filterPipe.transform(this.items, this.filterText)
if (filtered.length == 1) {
this.selectionModel.toggle(filtered[0].id)
if (this.editing) {
this.applyClicked()
} else {
this.dropdown.close()
}
}
}
}

View File

@ -6,7 +6,7 @@ import { MatchingModel } from '../data/matching-model';
name: 'filter'
})
export class FilterPipe implements PipeTransform {
transform(items: MatchingModel[], searchText: string): any[] {
transform(items: MatchingModel[], searchText: string): MatchingModel[] {
if (!items) return [];
if (!searchText) return items;