SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.24k stars 1k forks source link

Incorrect WebPart version when partial load applied after click on back in browser #8913

Open salascz opened 1 year ago

salascz commented 1 year ago

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

None

What browser(s) / client(s) have you tested

Additional environment details

Describe the bug / error

Hello, I have found a weird behaviour of partial page load for cases when you are working with different versions of the webpart.

Imagine you have a WebPart stored in tenant app catalog. The WebPart is in version v1. There is a quite long process to get the WebPart updated to new version in my company, so we are using Site application catalog to "override" the tenant version (e.g., v2). This is working perfectly when you working on same site or when you perform full reload - the site version (v2) of the script is loaded and WebPart is rendered correctly.

Imagine you have a link on the WebPart page that redirect users to other site, where the WebPart is used in v1 (loaded from tenant catalog). The v1 version of the WebPart is rendered correctly.

The issue occurs when the user use "Back" button in the browser to return to previous page (pointing to the site with v2 version of the WebPart) -> SharePoint use partial load (e.g., header is not refreshed), there seem to be 2 versions of the webpart script loaded and the tenant version (v1) wins :-( -> the webpart is not rendered correctly

It does not look like an issue on our side (I am experiencing this issue with quite well known "Modern Script Editor WebPart" or "PnP Modern Search" webparts

Thanks

Steps to reproduce

  1. Open a page with webpart (version v2, site app catalog)
  2. Click on the link pointing to page on another site using different version of the webpart (version v1, tenant app catalog)
  3. Click on "Back" button in the browser
  4. WebPart on page (from step 1) is not rendered correctly (version v1 from tenant is used instead v2)

Expected behavior

It should use the webpart script from site collection app catalog (at it would use after the page refresh)

ghost commented 1 year ago

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

AJIXuMuK commented 1 year ago

@salascz - thanks for submitting the issue.

First thing first - web parts from the tenant app catalog automatically update the scripts for all instances. It means if you upload v2 to the tenant app catalog all sites that use this web part will automatically serve v2 of the JS/CSS.

So, maybe your extra step with site collection app catalog is not needed.

However, the issue is still valid and we'll be looking into it.

salascz commented 1 year ago

@AJIXuMuK - you are correct, an update in the tenant app catalog would solve the issue. Unfortunately, such an update is quite difficult (time-consuming because of processes, SDLC, release planning, etc., and requires other team's involvement in our case). In opposition to this, I can make changes on site-collection level without any restriction.

Thanks for looking into it.