From 8aa35540b57a30818341e433bd4f1a73299b3bf7 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 16 Sep 2024 19:36:44 -0700 Subject: [PATCH] Fix a random test error --- .../filterable-dropdown.component.spec.ts | 7 +------ .../filterable-dropdown/filterable-dropdown.component.ts | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts index a285144f4..d1c37bc8b 100644 --- a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts +++ b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.spec.ts @@ -539,15 +539,10 @@ describe('FilterableDropdownComponent & FilterableDropdownSelectionModel', () => fixture.nativeElement .querySelector('button') .dispatchEvent(new MouseEvent('click')) // open - fixture.detectChanges() tick(100) component.filterText = 'FooBar' - fixture.detectChanges() - component.listFilterTextInput.nativeElement.dispatchEvent( - new KeyboardEvent('keyup', { key: 'Enter' }) - ) + component.listFilterEnter() expect(component.selectionModel.getSelectedItems()).toEqual([]) - tick(300) expect(createSpy).toHaveBeenCalled() })) diff --git a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts index 4a3c70953..7830e3909 100644 --- a/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts +++ b/src-ui/src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts @@ -483,7 +483,7 @@ export class FilterableDropdownComponent implements OnDestroy, OnInit { dropdownOpenChange(open: boolean): void { if (open) { setTimeout(() => { - this.listFilterTextInput.nativeElement.focus() + this.listFilterTextInput?.nativeElement.focus() }, 0) if (this.editing) { this.selectionModel.reset() @@ -492,7 +492,7 @@ export class FilterableDropdownComponent implements OnDestroy, OnInit { this.opened.next(this) } else { if (this.creating) { - this.dropdown.open() + this.dropdown?.open() this.creating = false } else { this.filterText = ''