Skip to content

[BUGFIX] Reset sticky query params with an explicit empty query hash - #21522

Closed
olenderhub wants to merge 1 commit into
emberjs:mainfrom
olenderhub:fix/reset-query-params-empty-hash
Closed

[BUGFIX] Reset sticky query params with an explicit empty query hash#21522
olenderhub wants to merge 1 commit into
emberjs:mainfrom
olenderhub:fix/reset-query-params-empty-hash

Conversation

@olenderhub

Copy link
Copy Markdown
Contributor

Summary

Sticky query params are preserved when @query / queryParams is omitted. There was previously no clean way to reset them without knowing every QP key.

An explicitly empty query object now resets to defaults for that transition:

  • <LinkTo @route="photos" @query={{(hash)}}> → defaults
  • router.transitionTo('photos', { queryParams: {} }) → defaults
  • Omitting @query / queryParams → sticky unchanged
  • A partial { queryParams: { page: 1 } } updates only supplied keys (not a full reset)

Reset hydrates defaults for the destination transition; it does not clear the sticky cache for other routes.

Compatibility: apps that used { queryParams: {} } / an empty @query hash as a no-op placeholder may observe a behavior change, because empty now means reset to defaults.

Closes #20211

Allow LinkTo `@query={{(hash)}}` and `{ queryParams: {} }` to restore
destination-route defaults for that transition, while omitting query
params preserves stickiness. Reset hydrates defaults and does not clear
the sticky cache for other routes.

Apps that used an empty query object as a no-op placeholder may observe
a behavior change.

Closes emberjs#20211
@NullVoxPopuli

Copy link
Copy Markdown
Contributor

Thanks for submitting this PR! however, while I understand the desire to fix #20211, and have an ergonomic way to solve the problem, we can't change this behavior because it would be a breaking change <3

I'm going to close this for now, as we have several techniques for resetting QPs already, and with a new route/router manager(s) on the way, we want to provide folks more ergonomic ways to customize their route/router behavior

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.

[Bug] No way to reset query parameters when transitioning to the same page

2 participants