Skip to content

Commit

Permalink
Merge pull request #379 from cultuurnet/UPS-4891
Browse files Browse the repository at this point in the history
UPS-4891 - Don't block AngularJS routing
  • Loading branch information
hirviid authored Mar 11, 2024
2 parents 14c6dfe + 4e38805 commit 861ba46
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ angular
eIDService.init();

var runningInIframe = isRunningInIframe();
var MAX_URL_DEPTH = 4;

$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
// Don't block any state changes if not running inside an iframe
Expand All @@ -171,16 +170,10 @@ angular
return;
}

// Don't redirect deeply nested routes. This gives weird behaviour in wizards because data is not kept between iframe loads.
var isDeeplyNested = to.split('/').length > MAX_URL_DEPTH;

if (isDeeplyNested) {
return;
}

if (runningInIframe && !toParams.forceAngularNavigation) {
// ! Don't disable Angular routing for now, NextJS will reload the iframe if necessary. This will make sure all routes keep working.
// Block the state change and emit the new path to the parent window for further handling.
event.preventDefault();
// event.preventDefault();
window.parent.postMessage({
source: 'BALIE',
type: 'URL_CHANGED',
Expand Down

0 comments on commit 861ba46

Please sign in to comment.