Fix a random test error

This commit is contained in:
shamoon 2024-09-16 19:36:44 -07:00
parent 6b76847595
commit 7f04c6a09a
2 changed files with 3 additions and 8 deletions

View File

@ -539,15 +539,10 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () =>
fixture.nativeElement fixture.nativeElement
.querySelector('button') .querySelector('button')
.dispatchEvent(new MouseEvent('click')) // open .dispatchEvent(new MouseEvent('click')) // open
fixture.detectChanges()
tick(100) tick(100)
component.filterText = 'FooBar' component.filterText = 'FooBar'
fixture.detectChanges() component.listFilterEnter()
component.listFilterTextInput.nativeElement.dispatchEvent(
new KeyboardEvent('keyup', { key: 'Enter' })
)
expect(component.selectionModel.getSelectedItems()).toEqual([]) expect(component.selectionModel.getSelectedItems()).toEqual([])
tick(300)
expect(createSpy).toHaveBeenCalled() expect(createSpy).toHaveBeenCalled()
})) }))

View File

@ -483,7 +483,7 @@ export class FilterableDropdownComponent implements OnDestroy, OnInit {
dropdownOpenChange(open: boolean): void { dropdownOpenChange(open: boolean): void {
if (open) { if (open) {
setTimeout(() => { setTimeout(() => {
this.listFilterTextInput.nativeElement.focus() this.listFilterTextInput?.nativeElement.focus()
}, 0) }, 0)
if (this.editing) { if (this.editing) {
this.selectionModel.reset() this.selectionModel.reset()
@ -492,7 +492,7 @@ export class FilterableDropdownComponent implements OnDestroy, OnInit {
this.opened.next(this) this.opened.next(this)
} else { } else {
if (this.creating) { if (this.creating) {
this.dropdown.open() this.dropdown?.open()
this.creating = false this.creating = false
} else { } else {
this.filterText = '' this.filterText = ''