From d5bb290b8e3d025418f4e49b96252a2ae91abc4d Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 5 Dec 2014 14:02:50 +1300 Subject: [PATCH] Don't update CMS preview on a CMS redirect The CMS preview causes unnecessary browser processing by loading a URL which should be considered "in transit" when a CMS redirect is set through the X-ControllerURL HTTP header. The CMS history processing will load this new URL, and cause a new preview URL to be loaded. Fixes https://github.com/silverstripe/silverstripe-translatable/issues/158 --- admin/javascript/LeftAndMain.Preview.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/admin/javascript/LeftAndMain.Preview.js b/admin/javascript/LeftAndMain.Preview.js index 7e8ff317d..e4b60639f 100644 --- a/admin/javascript/LeftAndMain.Preview.js +++ b/admin/javascript/LeftAndMain.Preview.js @@ -326,7 +326,10 @@ * Update preview whenever any panels are reloaded. */ 'from .cms-container': { - onafterstatechange: function(){ + onafterstatechange: function(e, data) { + // Don't update preview if we're dealing with a custom redirect + if(data.xhr.getResponseHeader('X-ControllerURL')) return; + this._initialiseFromContent(); } },