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

[BUG]: Set-PnPPage and Set-PnPPageTextPart is adding extra white spaces above and below of text when text web part content ends with a Line break in Modern SharePoint page #4740

Open
savitajaiswal123 opened this issue Feb 18, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@savitajaiswal123
Copy link

Reporting an Issue
Using Set-PnPPage to create the pages in multi-languages of SharePoint site and Set-PnPPageTextPart to update the content of a text web part on a modern SharePoint page. Which adding extra white spaces in text webpart just above the text and below.

Expected behavior

  1. Modern Page should be published in SharePoint site with no extra spaces in text webpart. Apart from used spaces in text webpart after the text.
  2. Modern Page text webpart content should be updated in SharePoint site with no extra spaces. Apart from used spaces in text webpart after the text.

Image

Actual behavior
It is adding extra white space just above and below the text in text web part.

Image

Steps to reproduce behavior

  1. Create a new Modern page
  2. Add a Text webpart(section)
  3. Add any text followed by a line break (new line-by pressing enter key) for adding extra space after the content
  4. Run below script to publish the page
  5. The published page now has extra paragraph tags (

    ) above and below the content in Text webpart
    The publishing works fine if no new line (line break) are added to the content in the end.

$siteURL = ""
$listName = "”
$identity = ""
$baseUri = ""

$appId = ""
$appSec = ""
Connect-PnPOnline $SiteURL -ClientId $appId -ClientSecret $appSec

# Publish the page

Set-PnPPage -Identity $identity -Publish

Log-Message "Script execution completed successfully."

}
Catch {
Log-Message "An unhandled exception occurred. Error: $_" -level "ERROR"
}
finally {
Write-Host "Done!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

}

Additional Info:

Updating the Text part content also adds extra paragraph tags (

) above and below the content
Set-PnPPageTextPart -Page $pageIdentity -InstanceId $textControl.InstanceId -Text $translatedControlText -ErrorAction Stop

What is the version of the Cmdlet module you are running?
PnP.PowerShell 2.99.89-nightly

Which operating system/environment are you running PnP PowerShell on?
Azure Functions

@savitajaiswal123 savitajaiswal123 added the bug Something isn't working label Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant