Sp-dev-docs: Navigating to pages within the same site causes the application customizer to bind multiple times

Created on 27 Mar 2018  ·  11Comments  ·  Source: SharePoint/sp-dev-docs

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

As of today, we notice on some tenants that application customizers are added multiple times to pages.

Here is an example of navigating seven times:

screenshot 2018-03-27 13 27 07

What is worse is that this seem to be caused for everything on the page. So also for the style elements which get added by SPFx solutions.

Initial page load;

screenshot 2018-03-27 13 29 33

After navigating seven times:

screenshot 2018-03-27 13 29 15

My solution only adds one to a page.

Observed Behavior

Check above.

Steps to Reproduce

Using the following guide and navigating to other pages will cause this behaviour: https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/get-started/using-page-placeholder-with-extensions

A quick workaround would be to change the private class variables to static class variables. Which is what @waldekmastykarz and I tested.

spfx-general tracked bug-confirmed

Most helpful comment

Ok, in the process of rolling out a fix. There was a checkin timing issue on the original fix. Will be working to avoid that in the future.

Apologies.
Pat


From: OliverZeiser notifications@github.com
Sent: Tuesday, March 27, 2018 10:44:44 AM
To: SharePoint/sp-dev-docs
Cc: Pat Miller (SHAREPOINT); Mention
Subject: Re: [SharePoint/sp-dev-docs] Navigating to pages within the same site causes the application customizer to bind multiple times (#1546)

If you navigate between two libraries or lists the same thing happens. So it is not only on pages...


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FSharePoint%2Fsp-dev-docs%2Fissues%2F1546%23issuecomment-376613482&data=02%7C01%7CPat.Miller%40microsoft.com%7C3da235199dc1447677a808d5940a6def%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636577694871346725&sdata=sOl9Aks7XeN9C2UKVG0A6qokiAm7pMg8e5HLbogx0r4%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FADl-SeFPPkbxQj7LddLDA2gBrlC2NCs9ks5tinqMgaJpZM4S8wkx&data=02%7C01%7CPat.Miller%40microsoft.com%7C3da235199dc1447677a808d5940a6def%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636577694871346725&sdata=Jxtd89HKFL7wXOdg0qGNb8ZZdcPDWTlNbhwtrceZCtA%3D&reserved=0.

All 11 comments

I am seeing the same issue on multiple tenants. This is a serious issue, please fix it and start testing your stuff before pushing it out to the customers.

I was about to report the exact same issue!

We're having the same issue. I believe this was previously fixed in #1464 but has reappeared today.

As a workaround I am checking if my menu component already exists in the header with the following:

const menuCheck = document.getElementById("swlstgMenu");

if (this.topPlaceholder.domElement && !menuCheck) {

...

}

@rmillener if you create topPlaceholder as a static variable it should also work.

So instead of doing this:

export default class CustomApplicationCustomizer extends BaseApplicationCustomizer<ICustomApplicationCustomizerProperties> {
  private topPlaceholder: PlaceholderContent;

You can change it as follows:

export default class CustomApplicationCustomizer extends BaseApplicationCustomizer<ICustomApplicationCustomizerProperties> {
  private static topPlaceholder: PlaceholderContent;

And you will have to update this.topPlaceholder to CustomApplicationCustomizer.topPlaceholder.

Thanks Elio, a much better solution.

Digging into this. Does it happen on lists and pages, or just pages?

@patmill Both, just checked. It seems to happen every time the page is changed without the browser refreshing.

Only happens when the browser doesn't do a full page refresh. In my case, every time I navigate to the document library, it triggers a full refresh, so it is good.

If you navigate between two libraries or lists the same thing happens. So it is not only on pages...

Ok, in the process of rolling out a fix. There was a checkin timing issue on the original fix. Will be working to avoid that in the future.

Apologies.
Pat


From: OliverZeiser notifications@github.com
Sent: Tuesday, March 27, 2018 10:44:44 AM
To: SharePoint/sp-dev-docs
Cc: Pat Miller (SHAREPOINT); Mention
Subject: Re: [SharePoint/sp-dev-docs] Navigating to pages within the same site causes the application customizer to bind multiple times (#1546)

If you navigate between two libraries or lists the same thing happens. So it is not only on pages...


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FSharePoint%2Fsp-dev-docs%2Fissues%2F1546%23issuecomment-376613482&data=02%7C01%7CPat.Miller%40microsoft.com%7C3da235199dc1447677a808d5940a6def%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636577694871346725&sdata=sOl9Aks7XeN9C2UKVG0A6qokiAm7pMg8e5HLbogx0r4%3D&reserved=0, or mute the threadhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FADl-SeFPPkbxQj7LddLDA2gBrlC2NCs9ks5tinqMgaJpZM4S8wkx&data=02%7C01%7CPat.Miller%40microsoft.com%7C3da235199dc1447677a808d5940a6def%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636577694871346725&sdata=Jxtd89HKFL7wXOdg0qGNb8ZZdcPDWTlNbhwtrceZCtA%3D&reserved=0.

@patmill Any idea when we can expect a fix for this? I have also noticed that when using the back and forward buttons that lead to a completely different SharePoint site, the placeholders remain even though on the site you navigated to the placeholders should not appear.

Was this page helpful?
0 / 5 - 0 ratings