Fix: section type detection for vertical sections with non-standard c…#1757
Open
nicolaor wants to merge 1 commit into
Open
Fix: section type detection for vertical sections with non-standard c…#1757nicolaor wants to merge 1 commit into
nicolaor wants to merge 1 commit into
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1757 +/- ##
==========================================
- Coverage 82.42% 81.25% -1.17%
==========================================
Files 416 637 +221
Lines 28590 45388 +16798
Branches 0 4778 +4778
==========================================
+ Hits 23565 36880 +13315
- Misses 5025 7099 +2074
- Partials 0 1409 +1409 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
Thanks for opening a PR. We will try to process it ASAP 👍 |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Pages — Vertical section type detection uses wrong column for ColumnFactor check #1756
Summary
Fixes a bug where pages with vertical section layouts (
TwoColumnRightVerticalSection,TwoColumnLeftVerticalSection,TwoColumnVerticalSection) are misclassified asOneColumnduring page loading. This causesArgumentOutOfRangeExceptionduring PnP provisioning when controls reference columns that don't exist in the incorrectly-typed section.Problem
In
Page.cs, the section type detection for 3-column sections with a vertical section column usessection.Columns[0].ColumnFactorto determine the layout type. However, theColumnslist order is determined by HTML parsing of the page content, and the vertical section column (layoutIndex=2, columnFactor=12) can appear at index 0 if its controls are rendered first in the HTML.When
Columns[0]is the vertical column (columnFactor=12), all theif/else ifchecks for factors 6, 4, and 8 fail, leaving the section type at the defaultOneColumn.Fix
Changed the detection to filter out the vertical section column (layoutIndex=2) before checking
ColumnFactor:else if (section.Columns.Count == 3) { - if (section.Columns[0].ColumnFactor == 6) + // Use the first non-vertical-section column for type detection, + // as the vertical column (layoutIndex=2) may appear first in the list + var firstMainColumn = section.Columns + .Where(c => c.LayoutIndex != 2) + .OrderBy(c => c.Order) + .FirstOrDefault(); + var mainColumnFactor = firstMainColumn?.ColumnFactor ?? 0; + + if (mainColumnFactor == 6) { section.Type = CanvasSectionTemplate.TwoColumnVerticalSection; } - else if (section.Columns[0].ColumnFactor == 4) + else if (mainColumnFactor == 4) { section.Type = CanvasSectionTemplate.TwoColumnRightVerticalSection; } - else if (section.Columns[0].ColumnFactor == 8) + else if (mainColumnFactor == 8) { section.Type = CanvasSectionTemplate.TwoColumnLeftVerticalSection; } }File changed
src/sdk/PnP.Core/Model/SharePoint/Pages/Internal/Page.cs— Section type detection in the page loading logic (around line 1488)Testing
Employee-onboarding-team-home.aspxpage from the standard SharePoint Employee onboarding team site template, which uses aTwoColumnRightVerticalSectionlayoutType="OneColumn", provisioning crashed withArgumentOutOfRangeExceptionType="TwoColumnRightVerticalSection", provisioning succeedsRelated