I have been trying to store my url states in a lightning community using the locationChange event, while testing in the Sitepreview, every time there is a change in my url, the event is fired, however, as soon as I published to production and navigation is fired in between 2 different page layouts, the locationChange event is not fired. For Example:
Button.cmp
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global" >
<aura:handler event="aura:locationChange" action="{!c.updateUrl}"/>
<aura:attribute name="lastUrl" type="String" />
<div class="cBackButton showMe">
<lightning:button variant="brand"
label="Back To last page"
onclick="{!c.goBack}" />
</div>
</aura:component>
controller.js
goBack : function (component) {
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
"url": "realtive url page within my community"
});
urlEvent.fire();
},
updateUrl : function (component) {
// Update the url everytime a change occurs
var updateUrl = window.location.href;
component.set('v.lastUrl', updateUrl);
},
I'm not sure if this is related to the following known issue, so I was wondering if anyone might have run across a similar (or the same) behavior, and if there is some kind of workaround to this. (otherwise, all I/we can do is wait for this to be fixed ¯_(ツ)_/¯ )