transitionTo will not transition to requested URL
Facing strange issue while trying to redirect from version.edit to products page while intercepting transition using willTransition callback. What happens there - I have willTransition to catch transition event, cancel it based on value of blockTransition , and show modal window(not confirm) asking if I want to leave the page. If I hit 'yes', I set my blockTransition to false, so that my willTransition next time will return true. Having this flag set to false, I do another this.transitionToRoute() call. However in the end I'm not redirected to my /products endpoint but rather to products/XX/versions/YY endpoint. If I just simply remove willTransition callback from route - everything works as intended. Any ideas what was done wrong, or is it a bug?
//routes
this.authenticatedRoute('products');
this.authenticatedRoute('version.show', { path: 'products/:productId/versions/:versionId' });
this.authenticatedRoute('version.edit', { path: 'products/:productId/versions/:versionId/edit' });
//controller
cancelEdit() {
this.transitionToRoute('products')
}
//route
willTransition(transition) {
if (this.controllerFor('version.edit').get('blockTransition')) {
this.controllerFor('version.edit').set('isConfirmForTransition', true);
this.controllerFor('version.edit').set('transitionUrl', transition.intent.url ? transition.intent.url : transition.intent.name);
if (!transition.intent.url && !transition.intent.name) {
this.controllerFor('version.edit').set('transitionParams', transition.intent.contexts);
}
transition.abort();
} else {
return true;
}
}
@avdept Have you reached out in the community chat (discord) / forum, https://emberjs.com/community/ ?
Typically we use the issue tracker to report bugs.
Next step is to create a simple reproduction in code that demonstrates your issue.
Often we use https://ember-twiddle.com/ or if that doesn't work for your use case a sample repository and link to it here.