SPFx WebPart on appagehost.aspx will be removed after a few seconds
Category
- [ ] Question
- [ ] Typo
- [x] Bug
- [ ] Additional article idea
Expected or Desired Behavior
We have created a WebPart to render as an application page, so we leave the supportedHosts in the manifest.json empty and use the apppagehost.aspx URL to render our WebPart. The url looks like this: {siteUrl}/_layouts/15/appPageHost.aspx?componentId={componentId}.
Observed Behavior
This method worked well for a long time, now we have a problem with our first release tenant, where the WebPart is removed after a few seconds.
Steps to Reproduce
Create a new WebPart with SPFx version 1.8.2 and use the apppagehost.aspx page to render your WebPart. Our tenant is running in the first release mode, it seems like that the other tenants are not affected.
Open the URL and the WebPart will be rendered:

After a few seconds:

Html here looks like there should be a loading spinner...

I debuged a little bit in the SharePoint js files and found a file https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_6c1243ef07241a9f41fe54d8c7adbc98.js which probably causes the issue. In this script a _clearChildren function is called that removes the content of the web part.

Any Suggestions what we could do to make it work again?
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Unless I'm mistaken, what you're doing isn't a supported scenario. That page is used to host components as tabs in Microsoft Teams. MSFT may have added logic to clear the page if a Teams context isn't detected to remove it from the page.
You may try using the current version of SPFx 1.9.1, but pretty sure this scenario isn't supported. The other option would be to set it as a full page app page to see if that works for your scenario.
Hmm I think that for the teams tabs teamshostedapp.aspx is used. In the SPFx 1.8 release notes MSFT announced that there is a static page under appPageHost.aspx that will host any component in an app page - https://github.com/SharePoint/sp-dev-docs/wiki/SharePoint-Framework-v1.8-release-notes#app-pages - We have been using this page for almost half a year and it has always worked very well.
If we set it as a full page app page, do we need to add a page to each site collection to have this app page avaiable? That was the big advantage from the apppagehost.aspx, which is already on every site and we can simply render our component there.
@db3005 - correct. This should be supported, and you don't need to create a one-off app page .aspx in the sitepages library per site. As to why the spinner clearing is removing it - that sounds like a bug.
Are you by any chance doing rendering inside your onInit function (or in a promise resolved by your onInit function)?
@patmill - No, I start my rendering only in the render function. Even if I render a single div, it will be removed after 4-6 seconds.
->

Could it relate to the webpart properties panel ? In my issue #5019 I found out that I can't view the properties panel after those webparts disappeared. If I click on normal ootb webparts they show properties panel just fine, and if I click back on my custom webpart it will still show the properties panel but after I save the page and refresh, the properties panel cannot be opened again and the wp will disappear from the page.
@patmill @andrewconnell - Any updates on this issue?
@patmill Any updates on this? This problem has reached our productive tenants.
We created a ticket yesterday and the support engineer told us that this topic is being worked on but he could not give and eta or an internal id for this problem.
This issue has been fixed and will be part of the next prod rollout.
@kemesfun The accepted practice in this repo is to leave issues open until the fix is actually implemented & confirmed resolved by the OP (/cc @VesaJuvonen)
Has the prod rollout already happened? We just retested this and is still not working.
@MrTantum Can you give more details of which release tenant you are on. I am getting an error now, but it is related to preloaded information on page and not with the webpart.
It is a pre-release tenant:

Tenant ID is: b92496b8-2082-44c9-8996-26a1d0e8e3f8
This is happening in my production. Not sure if relating to this but my custom web part disappear right after added to the page.
I recorded the screen for more defails: https://youtu.be/-2UWAyXuZTY
@OverkillTV I couldn't repro this issue using a prod tenant.
The issue that I get is 'TypeError: Cannot read property 'Content' of undefined'. This is a new issue and isn't related to the original issue
@db3005 can you confirm the issue has been resolved? MSFT (@kemesfun) stated the fix has been applied and rolledout.
@andrewconnell No, unfortunately the error still occurs. I created another standard SPFx WebPart without any changes and recorded the screen:

@OverkillTV I couldn't repro this issue using a prod tenant.
The issue that I get is 'TypeError: Cannot read property 'Content' of undefined'. This is a new issue and isn't related to the original issue
Yeah I have 2 prod tenants. One has this issue, the other doesn't so not really sure why. They are in standard release.
@db3005 can you do the following commands: ctrl-shift-f12. I want to see which version of sp-client you are using because it is likely that the farm that you are didn't receive the code changes that were made that resolved this issue. @OverkillTV It could be that your prod tenants are on two separate farms, so one has the newer code and the other doesn't. Can you confirm this?
@kemesfun here's the screenshot:

Is that enough for you to see the version?