diff --git a/src/app/components/shared/selectors/project-name-selector/project-name-selector.component.ts b/src/app/components/shared/selectors/project-name-selector/project-name-selector.component.ts index 9129178ed..2d46aad64 100644 --- a/src/app/components/shared/selectors/project-name-selector/project-name-selector.component.ts +++ b/src/app/components/shared/selectors/project-name-selector/project-name-selector.component.ts @@ -27,6 +27,7 @@ export class ProjectNameSelectorComponent implements OnInit, OnDestroy { public projectNames: string[] = []; public projectNamesFiltered = []; public projectName = ''; + public filterValue: string | null = null; private subs = new SubSink(); readonly maxProjectNameLength = 100; @@ -66,7 +67,11 @@ export class ProjectNameSelectorComponent implements OnInit, OnDestroy { ]).subscribe(([scenes, user]) => { if (user) { this.projectNames = [ ...user.job_names, ]; - this.projectNamesFiltered = [ ...user.job_names, ]; + if (this.filterValue) { + this.filterProjectNames(); + } else { + this.projectNamesFiltered = [ ...user.job_names, ]; + } } const projectNamesSet: Set = scenes @@ -116,8 +121,14 @@ export class ProjectNameSelectorComponent implements OnInit, OnDestroy { } else { filterValue = projectName.toLowerCase(); } + + this.filterValue = filterValue; + this.filterProjectNames(); + } + + private filterProjectNames() { this.projectNamesFiltered = this.projectNames.filter( - option => option.toLowerCase().includes(filterValue) + option => option.toLowerCase().includes(this.filterValue) ); }