From c2143c7eb5e5ef9a227a51a35c552228e2846ffd Mon Sep 17 00:00:00 2001 From: 4gray Date: Sun, 23 Aug 2026 09:19:33 +0200 Subject: [PATCH] fix(search): compare the echoed q in trimmed form in the echo guard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adoption trims, so a same-page imperative navigation still carrying a not-yet-rewritten untrimmed q adopts to exactly the applied state — syncing it could only cancel a pending debounce. Comparing the trimmed form closes that window. Co-Authored-By: Claude Fable 5 --- .../services/workspace-shell-search-sync.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libs/workspace/shell/feature/src/lib/workspace-shell/services/workspace-shell-search-sync.service.ts b/libs/workspace/shell/feature/src/lib/workspace-shell/services/workspace-shell-search-sync.service.ts index 50b9c1894..e41edeae1 100644 --- a/libs/workspace/shell/feature/src/lib/workspace-shell/services/workspace-shell-search-sync.service.ts +++ b/libs/workspace/shell/feature/src/lib/workspace-shell/services/workspace-shell-search-sync.service.ts @@ -162,10 +162,14 @@ export class WorkspaceShellSearchSyncService { // so back/forward re-applies what the entry carries even mid-typing. // `lastSuccessfulNavigation` is set immediately before `NavigationEnd` // is emitted, so it describes the navigation being handled here. + // + // The comparison trims `nextTerm` because adoption would too: a URL + // still carrying a not-yet-rewritten untrimmed `q` adopts to exactly + // the applied state, so syncing could only cancel a pending debounce. if ( previousUrl !== null && getRoutePath(url) === getRoutePath(previousUrl) && - nextTerm === this.appliedSearchQuery() && + nextTerm.trim() === this.appliedSearchQuery() && this.router.lastSuccessfulNavigation()?.trigger === 'imperative' ) { return;