sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Branding Application Extension sometimes loads before Placeholder's are in DOM

Open MaartenSundman opened this issue 8 years ago • 4 comments

Category

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

Observed Behavior

Occasionally we are seeing our branding extension fail to load due to the Top/Bottom placeholders not being present in the DOM yet. Not sure why this happens, I would expect these to always be present by the time the extension is loaded.

Steps to Reproduce

This doesn't happen regularly, and we have worked around it by adding this (its dirty but maybe something similar can be integrated in to future releases in to tryCreateContent): if(document.querySelectorAll("[data-sp-placeholder='Top']").length == 0) { window.setTimeout(() => this.onInit(),50); return; }

MaartenSundman avatar Oct 16 '18 20:10 MaartenSundman

https://github.com/SharePoint/sp-dev-docs/issues/2773

dgusoff avatar Oct 16 '18 20:10 dgusoff

Did you have tried the solution that @dgusoff commented?

KingKangMSFT avatar Oct 17 '18 07:10 KingKangMSFT

The correct solution to this is to hook onto the placeholders in your placeholderProvider.changedEvent handler. This even will fire when the placeholders are created, and any time they change. The sample code in this tutorial (https://docs.microsoft.com/en-us/sharepoint/dev/spfx/extensions/get-started/using-page-placeholder-with-extensions) does the right thing (as well as the wrong thing. Pull request made to clarify it)

patmill avatar Oct 17 '18 23:10 patmill

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 26 '20 06:01 msft-github-bot