Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Fix dialog double hash try2 #4117

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion js/jquery.mobile.navigation.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1003,6 +1003,16 @@ define( [
if( fromPage && fromPage[0] === toPage[0] && !settings.allowSamePageTransition ) { if( fromPage && fromPage[0] === toPage[0] && !settings.allowSamePageTransition ) {
isPageTransitioning = false; isPageTransitioning = false;
mpc.trigger( "pagechange", triggerData ); mpc.trigger( "pagechange", triggerData );

// Even if there is no page change to be done, we should keep the urlHistory in sync with the hash changes
if( settings.fromHashChange ) {
urlHistory.directHashChange({
currentUrl: url,
isBack: function() {},
isForward: function() {}
});
}

return; return;
} }


Expand Down Expand Up @@ -1034,6 +1044,9 @@ define( [
} }
} catch(e) {} } catch(e) {}


// Record whether we are at a place in history where a dialog used to be - if so, do not add a new history entry and do not change the hash either
var alreadyThere = false;

// If we're displaying the page as a dialog, we don't want the url // If we're displaying the page as a dialog, we don't want the url
// for the dialog content to be used in the hash. Instead, we want // for the dialog content to be used in the hash. Instead, we want
// to append the dialogHashKey to the url of the current page. // to append the dialogHashKey to the url of the current page.
Expand All @@ -1042,6 +1055,17 @@ define( [
// be an empty string. Moving the undefined -> empty string back into // be an empty string. Moving the undefined -> empty string back into
// urlHistory.addNew seemed imprudent given undefined better represents // urlHistory.addNew seemed imprudent given undefined better represents
// the url state // the url state

// If we are at a place in history that once belonged to a dialog, reuse
// this state without adding to urlHistory and without modifying the hash.
// However, if a dialog is already displayed at this point, and we're
// about to display another dialog, then we must add another hash and
// history entry on top so that one may navigate back to the original dialog
if ( active.url.indexOf( dialogHashKey ) > -1 && !$.mobile.activePage.is( ".ui-dialog" ) ) {
settings.changeHash = false;
alreadyThere = true;
}

url = ( active.url || "" ) + dialogHashKey; url = ( active.url || "" ) + dialogHashKey;
} }


Expand Down Expand Up @@ -1069,7 +1093,7 @@ define( [
|| ( isDialog ? $.mobile.defaultDialogTransition : $.mobile.defaultPageTransition ); || ( isDialog ? $.mobile.defaultDialogTransition : $.mobile.defaultPageTransition );


//add page to history stack if it's not back or forward //add page to history stack if it's not back or forward
if( !historyDir ) { if( !historyDir && !alreadyThere ) {
urlHistory.addNew( url, settings.transition, pageTitle, pageUrl, settings.role ); urlHistory.addNew( url, settings.transition, pageTitle, pageUrl, settings.role );
} }


Expand Down