From a7ff3a8272440ad38f66dddff7495dfd6c1a3704 Mon Sep 17 00:00:00 2001
From: shamoon <4887959+shamoon@users.noreply.github.com>
Date: Sun, 30 Aug 2026 10:19:53 -0700
Subject: [PATCH] Fix: set global search earlier to avoid awaiting debounce
(#13865)
---
.../global-search/global-search.component.html | 2 +-
.../global-search/global-search.component.spec.ts | 13 +++++++++++++
.../global-search/global-search.component.ts | 6 ++++++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/src-ui/src/app/components/app-frame/global-search/global-search.component.html b/src-ui/src/app/components/app-frame/global-search/global-search.component.html
index 06c77ac3d..e2748709e 100644
--- a/src-ui/src/app/components/app-frame/global-search/global-search.component.html
+++ b/src-ui/src/app/components/app-frame/global-search/global-search.component.html
@@ -9,7 +9,7 @@
autocomplete="off"
spellcheck="false"
[ngModel]="query()"
- (ngModelChange)="queryDebounce.next($event)"
+ (ngModelChange)="onQueryChange($event)"
(keydown)="searchInputKeyDown($event)"
ngbDropdownAnchor>
diff --git a/src-ui/src/app/components/app-frame/global-search/global-search.component.spec.ts b/src-ui/src/app/components/app-frame/global-search/global-search.component.spec.ts
index a497f3e50..9d0655ca4 100644
--- a/src-ui/src/app/components/app-frame/global-search/global-search.component.spec.ts
+++ b/src-ui/src/app/components/app-frame/global-search/global-search.component.spec.ts
@@ -272,6 +272,19 @@ describe('GlobalSearchComponent', () => {
expect(advancedSearchSpy).toHaveBeenCalled()
})
+ it('should set query immediately and run full search on enter without waiting for debounce', () => {
+ jest.useFakeTimers()
+ const searchSpy = jest.spyOn(searchService, 'globalSearch')
+ searchSpy.mockReturnValue(of({} as any))
+ const fullSearchSpy = jest.spyOn(component, 'runFullSearch')
+ component.onQueryChange('test')
+ expect(component.query()).toBe('test')
+ component.searchInputKeyDown(new KeyboardEvent('keydown', { key: 'Enter' }))
+ expect(fullSearchSpy).toHaveBeenCalled()
+ expect(searchSpy).not.toHaveBeenCalled()
+ jest.useRealTimers()
+ })
+
it('should search on query debounce', () => {
jest.useFakeTimers()
const query = 'test'
diff --git a/src-ui/src/app/components/app-frame/global-search/global-search.component.ts b/src-ui/src/app/components/app-frame/global-search/global-search.component.ts
index aea247b52..685810c42 100644
--- a/src-ui/src/app/components/app-frame/global-search/global-search.component.ts
+++ b/src-ui/src/app/components/app-frame/global-search/global-search.component.ts
@@ -119,6 +119,12 @@ export class GlobalSearchComponent implements OnInit {
})
}
+ public onQueryChange(text: string) {
+ // set immediately so Enter / the full search button work without waiting for the debounce
+ this.query.set(text)
+ this.queryDebounce.next(text)
+ }
+
public ngOnInit() {
this.hotkeyService
.addShortcut({ keys: '/', description: $localize`Global search` })