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

Commit c974abc

Browse files
author
Gabriel Schulhof
committed
Dialog: Retreat in the urlHistory stack when closing with history disabled. Fixes #5465.
1 parent b1d8a00 commit c974abc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

js/widgets/dialog.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,25 @@ $.widget( "mobile.dialog", $.mobile.widget, {
113113

114114
// Close method goes back in history
115115
close: function() {
116-
var dst;
116+
var idx, dst, hist = $.mobile.navigate.history;
117117

118118
if ( this._isCloseable ) {
119119
this._isCloseable = false;
120120
// If the hash listening is enabled and there is at least one preceding history
121121
// entry it's ok to go back. Initial pages with the dialog hash state are an example
122122
// where the stack check is necessary
123-
if ( $.mobile.hashListeningEnabled && $.mobile.urlHistory.activeIndex > 0 ) {
123+
if ( $.mobile.hashListeningEnabled && hist.activeIndex > 0 ) {
124124
$.mobile.back();
125125
} else {
126-
dst = $.mobile.urlHistory.getActive().url;
126+
idx = Math.max( 0, hist.activeIndex - 1 );
127+
dst = hist.stack[ idx ].pageUrl || hist.stack[ idx ].url;
128+
hist.previousIndex = hist.activeIndex;
129+
hist.activeIndex = idx;
127130
if ( !$.mobile.path.isPath( dst ) ) {
128131
dst = $.mobile.path.makeUrlAbsolute( "#" + dst );
129132
}
130133

131-
$.mobile.changePage( dst, { changeHash: false, fromHashChange: true } );
134+
$.mobile.changePage( dst, { direction: "back", changeHash: false, fromHashChange: true } );
132135
}
133136
}
134137
}

0 commit comments

Comments
 (0)