From 1e9409ade139eb8addd633c081e8f8a9800ca622 Mon Sep 17 00:00:00 2001
From: Dries Buytaert <dries@buytaert.net>
Date: Fri, 28 May 2010 19:11:42 +0000
Subject: [PATCH] - Patch #690288 by casey, klausi: back button in overlay
 doesn't work properly when there's redirection, e.g.
 #admin/structure/trigger.

---
 modules/overlay/overlay-parent.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/overlay/overlay-parent.js b/modules/overlay/overlay-parent.js
index f4688af69ace..64219b78298d 100644
--- a/modules/overlay/overlay-parent.js
+++ b/modules/overlay/overlay-parent.js
@@ -862,8 +862,9 @@ Drupal.overlay.fragmentizeLink = function (link) {
   // true to prevent transforming this link into a clean URL while clean URLs
   // may be disabled.
   var path = self.getPath(link, true);
-  // Preserve existing query and fragment parameters in the URL.
-  var destination = path + link.search + link.hash;
+  // Preserve existing query and fragment parameters in the URL, except for
+  // "render=overlay" which is re-added in Drupal.overlay.hashchangeHandler.
+  var destination = path + link.search.replace(/&?render=overlay/, '').replace(/\?$/, '') + link.hash;
 
   // Assemble and return the overlay-ready link.
   return $.param.fragment(window.location.href, { overlay: destination });
@@ -892,7 +893,8 @@ Drupal.overlay.syncChildLocation = function (childLocation) {
     // Set a 'redirect' flag on the new location so the hashchange event handler
     // knows not to change the overlay's content.
     $.data(window.location, newLocation, 'redirect');
-    window.location.href = newLocation;
+    // Using location.replace so we don't create an extra history entry.
+    window.location.replace(newLocation);
   }
 };
 
-- 
GitLab