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

SPFX Webpart not show up after added to sitepages

Open OverkillTV opened this issue 6 years ago • 7 comments

#4912 ## Category

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

Expected or Desired Behavior

After added successfully to the SitePages, spfx webpart should show up after refresh the page

Observed Behavior

After added successfully to the SitePages, spfx webpart show up and work normally but if the page is refreshed it will disappear from the page. Edit the page and duplicate the webpart seems to fix the issue.

Steps to Reproduce

  1. Add spfx webpart to the page
  2. Save & Publish the page.
  3. Refresh the page.

Additional Information

SPFX Version: 1.9.1

package.json:

{
  "name": "net-work-acquisition-dashboard",
  "version": "0.0.1",
  "private": true,
  "main": "lib/index.js",
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "build": "gulp bundle",
    "clean": "gulp clean",
    "test": "gulp test"
  },
  "dependencies": {
    "@material-ui/core": "^4.7.2",
    "@material-ui/icons": "^4.5.1",
    "@microsoft/sp-core-library": "1.9.1",
    "@microsoft/sp-lodash-subset": "1.9.1",
    "@microsoft/sp-office-ui-fabric-core": "1.9.1",
    "@microsoft/sp-webpart-base": "1.9.1",
    "@types/es6-promise": "0.0.33",
    "@types/react": "16.8.8",
    "@types/react-dom": "16.8.3",
    "@types/webpack-env": "1.13.1",
    "moment": "^2.24.0",
    "office-ui-fabric-react": "6.189.2",
    "react": "16.8.5",
    "react-dom": "16.8.5"
  },
  "devDependencies": {
    "@microsoft/sp-build-web": "1.9.1",
    "@microsoft/sp-tslint-rules": "1.9.1",
    "@microsoft/sp-module-interfaces": "1.9.1",
    "@microsoft/sp-webpart-workbench": "1.9.1",
    "@microsoft/rush-stack-compiler-2.9": "0.7.16",
    "gulp": "~3.9.1",
    "@types/chai": "3.4.34",
    "@types/mocha": "2.2.38",
    "ajv": "~5.2.2"
  },
  "resolutions": {
    "@types/react": "16.8.8"
  }
}

No errors show up in the developer console.

Thanks for your contribution! Sharing is caring.

OverkillTV avatar Dec 14 '19 01:12 OverkillTV

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Dec 14 '19 01:12 msft-github-bot

Appears to be a dupe of #5012?

andrewconnell avatar Dec 14 '19 13:12 andrewconnell

Appears to be a dupe of #5012?

I don't think this is a duplicate, since this is not a full page hack at the teams landing page.

BUT - I can confirm with no changes to our end, we have started getting similar reports on our SPFx web parts starting around last Friday (December 13) of the following:

  1. Web parts removed/missing after clicking publish and refreshing the page
  2. Changing web part properties and publishing will lose all changes and revert back to default after refreshing the page
  3. Editing the webpart, publishing and hitting edit again WITHOUT refresh will duplicate the content of the webpart on the page (this will be gone after a page refresh)

So seems like some update was pushed regarding how webparts are added/saved on modern pages that is breaking existing web parts.

So far I'm out of luck trying to see if this is our code causing it, and like I said - we did not publish a version for 2 weeks and it worked fine until Friday.

Hope this helps triaging the issue. IMHO this seems critical.

shaipetel avatar Dec 16 '19 16:12 shaipetel

Found out more info and updated our code with the fix. Just putting my observations here:

There has been a change in modern pages that made some updates to "this.properties.xyz = value" be ignored in some cases. It seems switching the code to always call "set(this.properties,'xyz', value)" followed by this.onPropertyPaneFieldChanged fixes this irregularity. The issue seems to happen more on my end if the webpart does not have the toolpane opened, but it is in design mode (the page is in edit mode). Used to work fine before Friday.

Second observation: when clicking edit/publish/edit/publish it used to behave differently as well. I'm not sure 100% how, but either the "this.renderedOnce" property is now re-set to false or the containing DIV in this.domElement used to be cleared and now it keeps the old content. Again, not sure which one of those changed but it led to our webpart appearing twice and one web part was gone after refresh.

Hope this helps, and again I'm not even sure if this is related to the original issue reported but I suspected it does (could be wrong, of course...?)

shaipetel avatar Dec 16 '19 17:12 shaipetel

Does this repro with the OOB HelloWorld web part? Is there a scoped code sample on GitHub for us to look at?

johnguy0 avatar Jan 30 '20 20:01 johnguy0

The issue doesn't happen anymore for both the new web parts and also the old ones who used to have this issue. The issue just simply went away during end of December 2019 not sure why. And yes it used to happen to OOTB HelloWorld web part as well.

OverkillTV avatar Feb 01 '20 02:02 OverkillTV

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 Feb 08 '20 06:02 msft-github-bot