Skip to content

Commit e708aa5

Browse files
claudeenko
authored andcommitted
fix(frontend): Debounce URL updates in search to prevent pushState spam
Move onQueryChange callback inside the debounced timeout to prevent excessive history.pushState() calls when typing quickly in the search input. Previously, the callback was called immediately on every keystroke which could trigger >100 pushState calls in 10 seconds, causing a SecurityError in browsers. Fixes: FREUNDEBUCH-FRONTEND-M
1 parent 9a5f604 commit e708aa5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

apps/frontend/src/lib/components/friends/FriendList.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ function handleSearchInput(value: string) {
9292
searchError = null;
9393
searchPage = 1; // Reset to first page on new search
9494
95-
// Notify parent of query change
96-
onQueryChange?.(value);
97-
9895
// Clear any pending debounce
9996
if (debounceTimer) {
10097
clearTimeout(debounceTimer);
@@ -108,12 +105,16 @@ function handleSearchInput(value: string) {
108105
searchTotal = 0;
109106
searchTotalPages = 0;
110107
isSearching = false;
108+
// Notify parent of query change (debounced to prevent pushState spam)
109+
onQueryChange?.(value);
111110
return;
112111
}
113112
114113
isSearching = true;
115114
116115
debounceTimer = setTimeout(async () => {
116+
// Notify parent of query change (debounced to prevent pushState spam)
117+
onQueryChange?.(value);
117118
await performSearch();
118119
}, 300);
119120
}

0 commit comments

Comments
 (0)