We have a use case where a lightning component built in LWC, should trigger a URL change.
We're handling that with the history.replaceState
method(note that we encountered the same problem with history.pushState
).
In the other hand, upon a URL change an Aura Component should rerender/reflect this change.
Problem:
Neither of the standard events forceCommunity:routeChange
or aura:locationChange
are able to pickup the URL change.
Is this a bug or these events are not supposed to pickup such kind of URL change?
Reproducing the problem:
In order to reproduce this scenario I've built a basic demo app, that can be found & deployed from this repo.
pushState
never causes a hashchange event to be fired and I belive the two salesforce events you have mentioned listen for this standard event to detect the change.pushState
/replaceStat
, both of them change the URL, and yes ifaura:locatonShange
detects on hash changes, theforceCommunity:routeChange
should detect it, at least as per what the documentation states: developer.salesforce.com/docs/component-library/bundle/…