-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MOBILE-4686 user-menu: Fix routes with canLeave cannot leave #4218
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -726,7 +726,13 @@ export class CoreNavigatorService { | |
* @returns Whether the current route page can block leaving the route. | ||
*/ | ||
currentRouteCanBlockLeave(): boolean { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your change is a breaking change that will break the usage in behat-blocking. IMO you should leave the previous function as it was and create a new one for the logout/switch account use case. |
||
return !!this.getCurrentRoute().snapshot?.routeConfig?.canDeactivate?.length; | ||
const canDeactivate = this.getCurrentRoute().snapshot?.routeConfig?.canDeactivate; | ||
|
||
if (!canDeactivate?.length) { | ||
return true; | ||
} | ||
|
||
return canDeactivate.every(method => typeof method === 'function' && method()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code doesn't work. The canDeactivate function (in here,
I checked the contents of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if we manage to fix this, I think this will cause a bad UX for the user. Your code is calling the After the user confirms that he wants to leave, the logout process will continue and this process performs a navigation to '/login/sites', which will trigger Angular's canDeactivate function again, displaying the confirm modal a second time. This is not what we want. |
||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're reversing the result of this function for no reason. Before, this function returned true if the route could block, now it returns false if it blocks, which doesn't make sense IMO.