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

Navigation between Single WebPart App Pages does not refresh WebPart content

Open salascz opened this issue 6 years ago • 11 comments

Category

  • [x] Bug

Describe the bug

I have a SPFx WebPart. The WebPart is placed on two Single WebPart App Pages (with different configuration for each page). Links to those pages are included to site navigation.

The WebPart is not refreshed if user click on the navigation link. (The page url and page title is updated correctly)

Steps to reproduce

The issue might be reproduced with standard WebPart (e.g. Hero)

  1. Create two different App Pages with a Hero WebPart
  2. Add links to those pages to site navigation
  3. Open first page and click on a link to second page in site navigation - the page url is changed but the WebPart is not refreshed

AppPageWPIssue

Expected behavior

  • The render method of the WebPart should be called with properties related to second page

Environment details (development & target environment)

  • Your Developer Environment: Windows 10 or MacOS 10.15.6
  • Target Environment: SharePoint Online
  • Framework: Node.js v10
  • Browser(s): Chrome v85
  • Tooling: SPFx v1.11.0

salascz avatar Sep 08 '20 09:09 salascz

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

msft-github-bot avatar Sep 08 '20 09:09 msft-github-bot

Hi salascz,

I am able to reproduce this error with the demo webpart:

test

I suspect this is a bug and caused by a special mechanism on Modern page : when a hyperlink is clicked, navigation to the page is achieved via a page router to avoid full refresh of the screen.

Baker Kong Microsoft SharePoint Community Support

kongmengfei avatar Oct 01 '20 09:10 kongmengfei

Hi @kongmengfei, thanks for preparing a demo WebPart. I agree with your observation, the page router mechanism is probably the root cause. Seems to be OK for "standard" Modern pages and only App pages are affected.

Is there a way, how to get it fixed?

Thanks

salascz avatar Oct 01 '20 09:10 salascz

@salascz just ran into this issue myself. Were you able to find a workaround?

parmira5 avatar Oct 09 '20 20:10 parmira5

@salascz just ran into this issue myself. Were you able to find a workaround?

Yes, I created two separate webparts (one for each configuration) and reference the same React component.

Not a good solution for large projects as each webpart increase the build time...

salascz avatar Oct 09 '20 20:10 salascz

@salascz just ran into this issue myself. Were you able to find a workaround?

Yes, I created two separate webparts (one for each configuration) and reference the same React component.

Not a good solution for large projects as each webpart increase the build time...

Also kind of a cruddy solution but I just went up the dom and grabbed the site nav elements and added the data-interception=off attribute to each. Hopefully this is resolved before this comes back to bite me.

parmira5 avatar Oct 09 '20 21:10 parmira5

Hello @salascz - sorry for the long delay. The issue seems to be fixed by now.

Could you please check if the bug is still appearing for you?

AJIXuMuK avatar Nov 24 '21 19:11 AJIXuMuK

Hello, @AJIXuMuK I am able to replicate the issue on Single WebPart App Pages using PnP Template (for page provisioning) and OOTB Image WebParts :(. Standard pages are OK I guess

Here is my xml template:

<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2019/09/ProvisioningSchema" Version="1.0"
                  DisplayName="Issue Page Template">
  <pnp:Templates>
    <pnp:ProvisioningTemplate ID="IssuePageTemplate" Version="1.0" BaseSiteTemplate="SITEPAGEPUBLISHING#0" DisplayName="Issue Page"
                              Scope="RootSite">
      <pnp:ClientSidePages>
        <pnp:ClientSidePage PageName="TestPage1.aspx" Publish="true" PromoteAsNewsArticle="false" Overwrite="true" Layout="SingleWebPartAppPage" EnableComments="false"
                            Title="TestPage1">
          <pnp:Sections>
            <pnp:Section Order="1" Type="OneColumnFullWidth">
              <pnp:Controls>
                <!-- Image control -->
                <pnp:CanvasControl WebPartType="Image" JsonControlData="{&quot;id&quot;: &quot;d1d91016-032f-456d-98a4-721247c305e8&quot;, &quot;instanceId&quot;: &quot;5fb5c954-0ed7-477d-8b12-f5a8fa0a40fc&quot;, &quot;title&quot;: &quot;Image&quot;, &quot;description&quot;: &quot;Add an image, picture or photo to your page including text overlays and ability to crop and resize images.&quot;, &quot;dataVersion&quot;: &quot;1.9&quot;, &quot;properties&quot;: {&quot;imageSourceType&quot;:2,&quot;captionText&quot;:&quot;&quot;,&quot;altText&quot;:&quot;&quot;,&quot;linkUrl&quot;:&quot;&quot;,&quot;overlayText&quot;:&quot;&quot;,&quot;fileName&quot;:&quot;&quot;,&quot;siteId&quot;:&quot;{sitecollectionid}&quot;,&quot;webId&quot;:&quot;{siteid}&quot;,&quot;listId&quot;:&quot;{listid:Documents}&quot;,&quot;uniqueId&quot;:&quot;b30ebc1b-6a8a-4c50-8d58-7b6cd235bf39&quot;,&quot;imgWidth&quot;:300,&quot;imgHeight&quot;:392,&quot;isFullWidth&quot;:true,&quot;alignment&quot;:&quot;Center&quot;,&quot;resizeCoefficient&quot;:1,&quot;resizeDesiredWidth&quot;:2513,&quot;fixAspectRatio&quot;:false}, &quot;serverProcessedContent&quot;: {&quot;htmlStrings&quot;:{},&quot;searchablePlainTexts&quot;:{},&quot;imageSources&quot;:{&quot;imageSource&quot;:&quot;https://{fqdn}{site}/Shared Documents/parker-blue.png&quot;},&quot;links&quot;:{},&quot;customMetadata&quot;:{&quot;imageSource&quot;:{&quot;siteId&quot;:&quot;{sitecollectionid}&quot;,&quot;webId&quot;:&quot;{siteid}&quot;,&quot;listId&quot;:&quot;{listid:Documents}&quot;,&quot;uniqueId&quot;:&quot;b30ebc1b-6a8a-4c50-8d58-7b6cd235bf39&quot;,&quot;imgWidth&quot;:300,&quot;imgHeight&quot;:392}}}, &quot;dynamicDataPaths&quot;: {}, &quot;dynamicDataValues&quot;: {}}" ControlId="d1d91016-032f-456d-98a4-721247c305e8" Order="1" Column="1" />
              </pnp:Controls>
            </pnp:Section>
          </pnp:Sections>
        </pnp:ClientSidePage>
        <pnp:ClientSidePage PageName="TestPage2.aspx" Publish="true" PromoteAsNewsArticle="false" Overwrite="true" Layout="SingleWebPartAppPage" EnableComments="false"
                            Title="TestPage2">
          <pnp:Sections>
            <pnp:Section Order="1" Type="OneColumnFullWidth">
              <pnp:Controls>
                <!-- Image control -->
                <pnp:CanvasControl WebPartType="Image" JsonControlData="{&quot;id&quot;: &quot;d1d91016-032f-456d-98a4-721247c305e8&quot;, &quot;instanceId&quot;: &quot;5fb5c954-0ed7-477d-8b12-f5a8fa0a40fc&quot;, &quot;title&quot;: &quot;Image&quot;, &quot;description&quot;: &quot;Add an image, picture or photo to your page including text overlays and ability to crop and resize images.&quot;, &quot;dataVersion&quot;: &quot;1.9&quot;, &quot;properties&quot;: {&quot;imageSourceType&quot;:2,&quot;captionText&quot;:&quot;&quot;,&quot;altText&quot;:&quot;&quot;,&quot;linkUrl&quot;:&quot;&quot;,&quot;overlayText&quot;:&quot;&quot;,&quot;fileName&quot;:&quot;&quot;,&quot;siteId&quot;:&quot;{sitecollectionid}&quot;,&quot;webId&quot;:&quot;{siteid}&quot;,&quot;listId&quot;:&quot;{listid:Documents}&quot;,&quot;uniqueId&quot;:&quot;b30ebc1b-6a8a-4c50-8d58-7b6cd235bf39&quot;,&quot;imgWidth&quot;:300,&quot;imgHeight&quot;:392,&quot;isFullWidth&quot;:true,&quot;alignment&quot;:&quot;Center&quot;,&quot;resizeCoefficient&quot;:1,&quot;resizeDesiredWidth&quot;:2513,&quot;fixAspectRatio&quot;:false}, &quot;serverProcessedContent&quot;: {&quot;htmlStrings&quot;:{},&quot;searchablePlainTexts&quot;:{},&quot;imageSources&quot;:{&quot;imageSource&quot;:&quot;https://{fqdn}{site}/Shared Documents/parker-green.png&quot;},&quot;links&quot;:{},&quot;customMetadata&quot;:{&quot;imageSource&quot;:{&quot;siteId&quot;:&quot;{sitecollectionid}&quot;,&quot;webId&quot;:&quot;{siteid}&quot;,&quot;listId&quot;:&quot;{listid:Documents}&quot;,&quot;uniqueId&quot;:&quot;b30ebc1b-6a8a-4c50-8d58-7b6cd235bf39&quot;,&quot;imgWidth&quot;:300,&quot;imgHeight&quot;:392}}}, &quot;dynamicDataPaths&quot;: {}, &quot;dynamicDataValues&quot;: {}}" ControlId="d1d91016-032f-456d-98a4-721247c305e8" Order="1" Column="1" />
              </pnp:Controls>
            </pnp:Section>
          </pnp:Sections>
        </pnp:ClientSidePage>
      </pnp:ClientSidePages>
    </pnp:ProvisioningTemplate>
  </pnp:Templates>
</pnp:Provisioning>

salascz avatar Nov 25 '21 11:11 salascz

Hi @salascz - you need to use a webpart that supports being in a single webpart app page - none of the out of the box webparts support this. If you have a custom webpart that supports the single webpart app page, and use the same process, does it work or not? Also - if you create the page manually (not using the PNP provisioning) does it work (we are unable to repro manually)?

patmill avatar Nov 29 '21 20:11 patmill

Hi @patmill, thank you for looking into our issue. Sorry, I thought out of the box webparts are supported as it was not possible to use not configured custom webparts when creating page from template (different story)

I can confirm it does work for pages created manually.

Looks like some kind of configuration issue on our side.

salascz avatar Nov 30 '21 10:11 salascz

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

ghost avatar Dec 07 '21 12:12 ghost