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

Fixes: Allow saving SP page with an existing collapsible section. Closes #6462 #6540

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mkm17
Copy link
Contributor

@mkm17 mkm17 commented Dec 29, 2024

Closes #6462
Changes in page clientsidewebpart add and page text add commands to handle existing collapsible sections when saving an SP page.

In this PR, I have also updated the page text add test file to align with the latest recommendations.

Just one comment, I believe we also need to add some handlers for the controlType":0,"pageSettingsSlice... element, which is also visible in the page context.

@milanholemans
Copy link
Contributor

Thanks @mkm17! We'll try to review it ASAP.

Just one comment, I believe we also need to add some handlers for the controlType":0,"pageSettingsSlice... element, which is also visible in the page context.

Could you clarify this a bit more, please?

@mkm17
Copy link
Contributor Author

mkm17 commented Dec 31, 2024

hi @milanholemans, I noticed that on a page, there is an additional element with controlType: 0 and some page settings. In the page text add command, during the changes to the command, this setting is omitted (during updates in clientsidepage.ts and Page.ts). In the page clientsidewebpart add command, as far as I remember, it is handled better, but the method used to add new parts to the page is implemented differently.

To be honest, I am not sure what we can do with it. I noticed that the clientsidepage.ts and Page.ts are also used in different commands. We could use a similar approach to page clientsidewebpart add and implement it in the page text add and other commands, or simply update page text add (and possibly other commands) to handle controlType:0.

@milanholemans
Copy link
Contributor

To be honest, I have no idea why we have Page.ts and clientsidepage.ts. It feels like it should be one util file.
Do you have more info about this @pnp/cli-for-microsoft-365-maintainers?

@Adam-it
Copy link
Member

Adam-it commented Jan 5, 2025

To be honest, I have no idea why we have Page.ts and clientsidepage.ts. It feels like it should be one util file. Do you have more info about this @pnp/cli-for-microsoft-365-maintainers?

no idea and I totally don't remember this part 😅.
IMO if we may align and keep things consistent than we should align for sure

@Adam-it Adam-it self-assigned this Jan 5, 2025
@Adam-it
Copy link
Member

Adam-it commented Jan 23, 2025

@mkm17 I was testing those changes on my tenant for the last couple of days and I noticed some behaviors that seem awkward to me and I think it would be good if we could clarify that before we proceed.
first I noticed the spo page clientsidewebpart add works properly but when I added the --order option it seems to break the section.
Please check the recording with my test for more context

spoclientsidewebpart.mp4

As for the spo page text add I also noticed it breaks for example the set color of the section

spopagetext.mp4

Please let me know what you think. 🙏

@Adam-it Adam-it marked this pull request as draft January 23, 2025 21:50
@mkm17
Copy link
Contributor Author

mkm17 commented Jan 24, 2025

Hi @Adam-it, I have reproduced the first issue, so I will change it and add a test to the test file.

Regarding the page text add command, the problem is that this is the only page update command that uses the Page.ts and clientsitepage.ts files to modify page content. The rest, such a page clientsidewebpart add, page control set, page header set, page section add` have their own implementation.

Page.ts and clientsitepage.ts do not handle controlType: 14, which is the background section setting, as well as controlType: 0, which is the page settings. (it is treated as empty sections, so possibly in your test, you noticed that you have an additional empty section added).

As I do not want to make big changes in this fix, maybe for now I can grab the code from page clientsidewebpart add, extract it into a reusable file, and use it in page text add, as it should be the same code, simply the control type is different.

After that, we will have a situation where all get commands will use Page.ts and all update ones will use custom code. So the next steps to consider would be:

  1. Should we extract code from all update commands into one reusable file?
  2. Should we change the Page.ts approach to be used for all cases?
  3. Should we use the update command approach in get commands?

And totally out of scope, should page updates be handled differently (to make all changes in page content locally and save the page with one request)?

I am adding @milanholemans because I saw his changes in clientsitepages add in the history, and his code looks easier to handle in the future than the one from Page.ts and clientsitepage.ts.

@mkm17
Copy link
Contributor Author

mkm17 commented Jan 25, 2025

Ok, please skip my last comment for a moment. I started checking the Page.ts and ClientSidePage.ts approach because the changes to include more information would also be needed in other commands that use these files.

@mkm17 mkm17 force-pushed the issues/6462_enchancement_collapsible_sections_fix branch from 9744391 to eac65a3 Compare January 26, 2025 22:46
@mkm17 mkm17 force-pushed the issues/6462_enchancement_collapsible_sections_fix branch from eac65a3 to 0c5087d Compare January 26, 2025 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Allow adding text to an existing collapsible section using spo page text add
3 participants