Forum Discussion
Matthew2370
Nov 01, 2021Copper Contributor
SharePoint Online Webparts Not Loading Correctly Until Page Refresh
I have multiple SharePoint Online site collections that are all exhibiting the same problem with certain webparts. When a page loads that contains a quicklinks, hero app, or weather app, the wep part...
Scrum5
Jan 28, 2022Copper Contributor
I am experiencing the same, have you resolved this? Matthew2370
Spocker
Feb 02, 2022Copper Contributor
Hey Scrum5,
I ultimately had to get into the Type/Javascript level on this to get it to work (window, etc). Managed to nail it down by adding this to my Init code in the SPFX web-part. Hope it helps you!
*****
protected async onInit(): Promise<void> {
await super.onInit();
navterm = window.location.pathname.substring(window.location.pathname.lastIndexOf('/') + 1);
((history) => {
var pushState = history.pushState;
history.pushState = (state, key, path) => {
pushState.apply(history, [state, key, path]);
this._onUrlChange();
};
})(window.history);
window.addEventListener('popstate', function (e) {
// Currently browsing by the browser history buttons ( back / forward )
// doesn't cause any effect on a sp conditionally loaded page.
// this._onUrlChange();
});