Skip to content

Commit 85e5754

Browse files
committed
refactor(useGlobalSearch): improve formatting and cancel in-flight updates
- Enhanced code readability by formatting multi-line function calls and conditions. - Added cancellation for in-flight URL and search query updates to prevent unintended navigation and value restoration.
1 parent 364c842 commit 85e5754

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

app/composables/useGlobalSearch.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ export function useGlobalSearch(place: 'header' | 'content' = 'content') {
151151
() => route.name,
152152
name => {
153153
if (name !== 'index') return
154+
// Drop any in-flight URL/commit updates so they can't navigate
155+
// back to /search or revive the old committed value after reset.
156+
updateUrlQuery.cancel()
157+
commitSearchQuery.cancel()
154158
searchQuery.value = ''
155159
committedSearchQuery.value = ''
156160
// Use nextTick so we run after the homepage has rendered.

0 commit comments

Comments
 (0)