Skip to content

fix(useSearchParams): skip no-op URL updates - #429

Open
ejsmith wants to merge 1 commit into
svecosystem:mainfrom
ejsmith:agent/avoid-no-op-search-param-navigation
Open

fix(useSearchParams): skip no-op URL updates#429
ejsmith wants to merge 1 commit into
svecosystem:mainfrom
ejsmith:agent/avoid-no-op-search-param-navigation

Conversation

@ejsmith

@ejsmith ejsmith commented Aug 10, 2026

Copy link
Copy Markdown

Summary

  • stop set() and update() before replacing reactive cache state when validation and serialization produce the value already stored
  • skip goto() when the final serialized search parameters already match the browser URL, including when a debounced callback eventually runs
  • avoid reactive cache and URL writes when reset() already represents the requested default state
  • cover coercion-equivalent numbers, equivalent Date instances, batch updates, and no-op resets in browser scenarios

Why

useSearchParams compares incoming values before schema validation. Inputs that appear different before validation, such as assigning "1" to a coerced number field, can validate and serialize back to the current value. The existing path still replaced the reactive cache and scheduled a navigation, even though the resulting URL was unchanged.

This can create unnecessary reactive feedback and duplicate SvelteKit navigations for normalization code that writes validated values back to the search-param proxy.

Validation

  • pnpm -F runed check
  • pnpm -F runed exec vitest --run (246 tests)
  • pnpm -F runed exec playwright test src/lib/utilities/use-search-params/use-search-params.scenarios.spec.ts --workers=1 (100 tests)
  • pnpm lint

@changeset-bot

changeset-bot Bot commented Aug 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7afd652

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ejsmith
ejsmith marked this pull request as ready for review August 10, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant