emberjs / emberjs/ember.js

[Bug] Queryparam value lost after transitionTo/abort in beforeModel

Open
#19,310 4 comments 0 reactions 0 assignees View on GitHub
Routing
Dominant language
TypeScript
Stars
22.6k
Forks
4.2k
Avg merge
3d 12h
Merged PRs (30d)
15

Description

### 🐞 Describe the Bug
Query parameter value seems to be lost after switching to a route that has an implicit/explicit abort in the beforeModel hook.

Note: we've seen several query param issues here recently, but these mainly seem to be related to intermediate transitions. We're not using loading substates here.

### 🔬 Minimal Reproduction
* Checkout the [reproduction repository](https://github.com/janvandevelde/Ember-beforeModel-transitionTo-test)
* `yarn install` & `ember s`
* Go to `http://localhost:4200/super-blog-reg-route`
* Click `Toggle Query param value button` (sets a query parameter of current route to true).
* Navigate to `Regular route (with beforeModel)` using the linkTo at the top of the page (this route has a beforeModel with a transitionTo in order to add a new query parameter)
* Navigate back to `Super-blog (regular route)` using the linkTo at the top of the page

### 😕 Actual Behavior
* Our starting route `super-blog-reg-route` has a query parameter with a value (`queryParamTest=true`)
* Switch to another route `Regular route (with beforeModel)` with a transitionTo in the beforeModel (implicit abort)
* If we switch back to the `super-blog-reg-route` route the `queryParamTest` value is gone

Note: The query parameter value of the original route seems to be remembered correctly if no transitionTo happens.

### 🤔 Expected Behavior
When switching back to the `super-blog-reg-route`, I'd expect that the `queryParamTest` value is always remembered (https://guides.emberjs.com/v3.16.0/routing/query-params/#toc_sticky-query-param-values).

### 🌍 Environment

- Ember: tested in version `3.16.10` & `3.23.1`
- Node.js/npm: 6.9.0
- OS: macOS Catalina 10.15.5
- Browser: Chrome 87.0.4280.88

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.