Skip to content
This repository
Browse code

[navigation] Do not change hash nor add history entry when displaying…

… a dialog at a history entry that already has dialogHashKey -- Fixes: #2656
  • Loading branch information...
commit 358f7de7d7429fca11b7050e281954bbdbe08559 1 parent 851fad0
Gabriel "_|Nix|_" Schulhof authored

Showing 1 changed file with 15 additions and 1 deletion. Show diff stats Hide diff stats

  1. 16  js/jquery.mobile.navigation.js
16  js/jquery.mobile.navigation.js
@@ -1044,6 +1044,9 @@ define( [
1044 1044
 			}
1045 1045
 		} catch(e) {}
1046 1046
 
  1047
+		// 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
  1048
+		var alreadyThere = false;
  1049
+
1047 1050
 		// If we're displaying the page as a dialog, we don't want the url
1048 1051
 		// for the dialog content to be used in the hash. Instead, we want
1049 1052
 		// to append the dialogHashKey to the url of the current page.
@@ -1052,6 +1055,17 @@ define( [
1052 1055
 			// be an empty string. Moving the undefined -> empty string back into
1053 1056
 			// urlHistory.addNew seemed imprudent given undefined better represents
1054 1057
 			// the url state
  1058
+
  1059
+			// If we are at a place in history that once belonged to a dialog, reuse
  1060
+			// this state without adding to urlHistory and without modifying the hash.
  1061
+			// However, if a dialog is already displayed at this point, and we're
  1062
+			// about to display another dialog, then we must add another hash and
  1063
+			// history entry on top so that one may navigate back to the original dialog
  1064
+			if ( active.url.indexOf( dialogHashKey ) > -1 && !$.mobile.activePage.is( ".ui-dialog" ) ) {
  1065
+				settings.changeHash = false;
  1066
+				alreadyThere = true;
  1067
+			}
  1068
+
1055 1069
 			url = ( active.url || "" ) + dialogHashKey;
1056 1070
 		}
1057 1071
 
@@ -1079,7 +1093,7 @@ define( [
1079 1093
 			|| ( isDialog ? $.mobile.defaultDialogTransition : $.mobile.defaultPageTransition );
1080 1094
 
1081 1095
 		//add page to history stack if it's not back or forward
1082  
-		if( !historyDir ) {
  1096
+		if( !historyDir && !alreadyThere ) {
1083 1097
 			urlHistory.addNew( url, settings.transition, pageTitle, pageUrl, settings.role );
1084 1098
 		}
1085 1099
 

0 notes on commit 358f7de

Please sign in to comment.
Something went wrong with that request. Please try again.