Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Ensure that the search snaps back to the original state when clicking outside or canceling the search under the condition that no value has been entered yet

Henriette Dargecedde4a9772c
diff --git a/frontend/src/app/core/global_search/input/global-search-input.component.html b/frontend/src/app/core/global_search/input/global-search-input.component.html
index 13f26dd12eb..61491b30798 100644
--- a/frontend/src/app/core/global_search/input/global-search-input.component.html
+++ b/frontend/src/app/core/global_search/input/global-search-input.component.html
@@ -26,11 +26,12 @@
[searchFn]="customSearchFn"
[virtualScroll]="false"
(focus)="onFocus()"
+ (blur)="onFocusOut()"
(search)="search($event)"
(close)="onClose()"
(change)="followItem($event)"
(keydown.enter)="onEnterBeforeResultsLoaded()"
- (keydown.escape)="blur()"
+ (keydown.escape)="onFocusOut()"
(clear)="clearSearch()"
[filters]="autocompleterOptions.filters"
[resource]="autocompleterOptions.resource"
diff --git a/frontend/src/app/core/global_search/input/global-search-input.component.ts b/frontend/src/app/core/global_search/input/global-search-input.component.ts
index cebe005a1e2..aa2e8291087 100644
--- a/frontend/src/app/core/global_search/input/global-search-input.component.ts
+++ b/frontend/src/app/core/global_search/input/global-search-input.component.ts
@@ -251,6 +251,8 @@ export class GlobalSearchInputComponent implements AfterViewInit, OnDestroy {
this.selectedItem = undefined;
this.toggleTopMenuClass();
}
+
+ (<HTMLInputElement>document.activeElement).blur();
}
public onClose():void {
@@ -467,11 +469,6 @@ export class GlobalSearchInputComponent implements AfterViewInit, OnDestroy {
}
}
- public blur():void {
- this.ngSelectComponent.ngSelectInstance.searchTerm = '';
- (<HTMLInputElement>document.activeElement).blur();
- }
-
private get currentScope():string {
const serviceScope = this.globalSearchService.projectScope;
return (serviceScope === '') ? 'current_project_and_all_descendants' : serviceScope;