Skip to content

Collapsible sections with webparts in ClientSidePages are not provisioned correctly #833

@mmi-wp

Description

@mmi-wp

Category

  • Bug

Describe the bug

When extracting a ClientSidePage to provision on a different SharePoint site, the resulting ClientSidePage is different from the extracted one. Here is an image of the page I'm extracting:

image

And here is an image after the extracted page is provisioned on a different SharePoint site:

image

Problems:

The section containing a webpart is not collapsible.
The vertical section gets the same collapsible settings as the top section.

Steps to reproduce

  1. Create a client side page with a vertical section, and a collapsible section containing a webpart
  2. Extract the ClientSidePage provisioning template using PnP.Framework ClientSidePageContentsHelper.ExtractClientSidePage();
  3. Apply the extracted provisioning template to a different sharepoint site.

Expected behavior

I am expecting the provisioned ClientSidePage to look the same as the extracted one. (See images above)

Environment details (development & target environment)

  • SDK version: 1.8
  • OS: Windows 10
  • SDK used in: ASP.Net Web App
  • Framework: .Net Framework 4.8
  • Browser(s): Chrome v109
  • Tooling: Visual Studio 2019

Additional context

I think the problem might be located in PageWebPart.cs. Here's a snippet of the code responsible for setting the section collapsible. Note that setting the Type = 1 renders the section as collapsible, as expected.

controlData.ZoneGroupMetadata = new SectionZoneGroupMetadata()
{
    // Set section type to 1 if it was not set (when new sections are added via code)
    Type = (Section as CanvasSection).SectionType,
    DisplayName = Section.DisplayName,
    IsExpanded = Section.IsExpanded,
    ShowDividerLine = Section.ShowDividerLine,
};

In PageText.cs that same snippet of code reads like this. I suspect maybe the PageWebPart.cs code should be the same.

controlData.ZoneGroupMetadata = new SectionZoneGroupMetadata()
{
    // Set section type to 1 if it was not set (when new sections are added via code)
    Type = (Section as CanvasSection).SectionType == 0 ? 1 : (Section as CanvasSection).SectionType,
    DisplayName = Section.DisplayName,
    IsExpanded = Section.IsExpanded,
    ShowDividerLine = Section.ShowDividerLine,
};

As for the issue with the vertical section taking the same collapsible settings as the first section, I think it should just not be possible to mark a vertical section as collapsible, since it's not possible in the editor. Checking if the section is a vertical section before setting ZoneGroupMetadata.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions