mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
🐛 Fixed browser back button behaviour after clicking "x posts" on tags screen (#1306)
closes https://github.com/TryGhost/Ghost/issues/11057 - removed static "replace" configuration of posts/pages query params - used the router service to register a `willTransition` event handler which handles conditional replaceState transition behaviour only when filters are changed whilst already on the posts/pages route
This commit is contained in:
parent
0ba331ec5f
commit
4a11a72ea2
1 changed files with 22 additions and 16 deletions
|
@ -5,30 +5,36 @@ import {inject as service} from '@ember/service';
|
||||||
|
|
||||||
export default AuthenticatedRoute.extend({
|
export default AuthenticatedRoute.extend({
|
||||||
infinity: service(),
|
infinity: service(),
|
||||||
|
router: service(),
|
||||||
|
|
||||||
queryParams: {
|
queryParams: {
|
||||||
type: {
|
type: {refreshModel: true},
|
||||||
refreshModel: true,
|
author: {refreshModel: true},
|
||||||
replace: true
|
tag: {refreshModel: true},
|
||||||
},
|
order: {refreshModel: true}
|
||||||
author: {
|
|
||||||
refreshModel: true,
|
|
||||||
replace: true
|
|
||||||
},
|
|
||||||
tag: {
|
|
||||||
refreshModel: true,
|
|
||||||
replace: true
|
|
||||||
},
|
|
||||||
order: {
|
|
||||||
refreshModel: true,
|
|
||||||
replace: true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
modelName: 'post',
|
modelName: 'post',
|
||||||
|
|
||||||
perPage: 30,
|
perPage: 30,
|
||||||
|
|
||||||
|
init() {
|
||||||
|
this._super(...arguments);
|
||||||
|
|
||||||
|
// if we're already on this route and we're transiting _to_ this route
|
||||||
|
// then the filters are being changed and we shouldn't create a new
|
||||||
|
// browser history entry
|
||||||
|
// see https://github.com/TryGhost/Ghost/issues/11057
|
||||||
|
this.router.on('routeWillChange', (transition) => {
|
||||||
|
if (transition.to && (this.routeName === 'posts' || this.routeName === 'pages')) {
|
||||||
|
let toThisRoute = transition.to.find(route => route.name === this.routeName);
|
||||||
|
if (transition.from && transition.from.name === this.routeName && toThisRoute) {
|
||||||
|
transition.method('replace');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
model(params) {
|
model(params) {
|
||||||
return this.session.user.then((user) => {
|
return this.session.user.then((user) => {
|
||||||
let queryParams = {};
|
let queryParams = {};
|
||||||
|
|
Loading…
Add table
Reference in a new issue