Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Page.cs and CanvasColumn.cs to handle collapsible sections correctly #1499

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

mkm17
Copy link

@mkm17 mkm17 commented Jul 26, 2024

As mentioned in issue #1497, the following PR contains a fix for collapsible sections in SharePoint pages.

@jansenbe jansenbe self-assigned this Aug 16, 2024
@jansenbe
Copy link
Contributor

Hey @mkm17 ,

I've just verified that our collapsible section test is working as expected (https://github.com/pnp/pnpcore/blob/dev/src/sdk/PnP.Core.Test/SharePoint/PagesTests.cs#L828-L910). Can you first verify that this is not working for you?

@mkm17
Copy link
Author

mkm17 commented Aug 23, 2024

Hi @jansenbe, sorry for the delay in response. I've been quite busy lately.

In my testing, I tried adding some collapsible sections to the same page. The issue appears when there's already a collapsible section on the page. and I tried to add another one, I noticed that all properties related to the collapse function disappeared from the properties.

image

For this page, I get this result ->

image

Then, when we save the page, all previously set collapsible sections are, of course, gone. Maybe this issue occurs only with empty sections, but I still think we should address it.

In the end, the result of the provided code is three empty sections.
image

I hope that I haven't overlooked anything, like the version or any obvious settings. Let me know if you can reproduce the same behavior.

My changes should resolve this issue, but since I'm not fluent with this repo, I hope they were added correctly.

@jansenbe
Copy link
Contributor

@mkm17 : can you verify that when then sections have content the same problem occurs?

@mkm17
Copy link
Author

mkm17 commented Aug 30, 2024

Hi @jansenbe, the sections with web parts are fine.

The page before adding the section:
image

The page after adding the section (the section without web parts has been cleared):
image

If you need any further research, I’m here to help!

@jansenbe
Copy link
Contributor

@mkm17 : so the only issue is only with empty sections...not sure if we really need this as empty sections collapsed or not collapsed is almost the same

@mkm17
Copy link
Author

mkm17 commented Aug 30, 2024

@jansenbe, hi, and thank you for your comment. The same thing happens when saving an empty collapsible section, so this code without control inside does not work (at least in my case): https://pnp.github.io/pnpcore/using-the-sdk/pages-intro.html#configuring-page-sections.

To add a little bit of background on why I am pushing for this change, I wanted to extend this command in PnP PowerShell: https://pnp.github.io/powershell/cmdlets/Add-PnPPageSection.html. Without the possibility to add a collapsible section to an empty section, it will be impossible to extend this command.

If adding the next empty collapsible section resets all previous empty ones, then it won't be possible to add more empty sections using these commands in the future:

Add-PnPPageSection -Page "Test" -SectionTemplate TwoColumn -IsCollapsibleSection -IconAlignment Right -DisplayName "Section PnP7"
Add-PnPPageSection -Page "Test" -SectionTemplate TwoColumn -IsCollapsibleSection -IconAlignment Right -DisplayName "Section PnP8"

Of course, it is not a crucial change, so if it is better not to touch this part of the code in PnP Core, then I will just extend the PnP PowerShell commands like Add-PnPPageWebPart, which should work with the current setup. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants