-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[NET10.0] Change ContentPage SafeAreaEdges default to None for consistent edge-to-edge behavior #31926
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
base: net10.0
Are you sure you want to change the base?
Conversation
…avior Co-authored-by: PureWeen <[email protected]>
Co-authored-by: PureWeen <[email protected]>
|
||
// Default to None (edge-to-edge) when user hasn't set any value | ||
// This ensures consistent behavior across iOS, Android, and Mac Catalyst | ||
return SafeAreaRegions.None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot I think this is the only change that we need in this file.
we just need to change the default to None for platforms other than ios/catalyst
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated ContentPage.cs with the minimal change - only changed the Android default from Container
to None
in the #else
block. The iOS/Mac Catalyst behavior with legacy IgnoreSafeArea
is preserved. (commit 1f8e702)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot I think we can revert these changes.
The default for IgnoreSafeArea is going to true which will default to None
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the Page.cs changes. The default for IgnoreSafeArea
is true
which correctly defaults to None
. (commit 1f8e702)
Co-authored-by: PureWeen <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot remove the changes to Layout and SCrollView from this PR
Just keep the changes that were made to ContentPage and the test fixes required for those changes
…Page changes Co-authored-by: PureWeen <[email protected]>
Removed changes to Layout and ScrollView. The PR now only contains the ContentPage change (Android default from |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
…ring additive offsets
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
…iew dimension checks
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
@copilot can you update the description on this PR based on all the changes made? Can you make a note how all the iOS screen shot changes are because we are now setting the SafeAreaEdges on the "ContentPages" to "Container" This is going to cause the images on the iOS screenshots to change because before we were basically doing "none" for iOS and "Container" for Android since these values weren't configurable. |
/azp run MAUI-UITests-public |
Azure Pipelines successfully started running 1 pipeline(s). |
Updated the PR description to reflect all changes made, including the explicit SafeAreaEdges settings in test files and the explanation of iOS screenshot changes. |
Summary
This PR changes the ContentPage SafeAreaEdges default to return
None
on Android when the user hasn't explicitly set a value, ensuring consistent edge-to-edge behavior across iOS, Android, and Mac Catalyst platforms.Problem
Previously, ContentPage had different default safe area behaviors across platforms:
None
via legacyIgnoreSafeArea
(edge-to-edge) ✅None
via legacyIgnoreSafeArea
(edge-to-edge) ✅Container
(safe area padding) ❌This inconsistency made it difficult for developers to predict layout behavior across platforms and led to unexpected UI rendering.
Solution
Updated ContentPage to default to
None
(edge-to-edge) on Android when the user hasn't specified safe area behavior:Changes Made
ContentPage (
src/Controls/src/Core/ContentPage/ContentPage.cs
)Container
toNone
in the#else
blockIgnoreSafeArea
property which defaults totrue
→None
)SafeAreaExtensions (
src/Core/src/Platform/Android/SafeAreaExtensions.cs
)Test Updates (Multiple test files in
TestCases.HostApp
)SafeAreaEdges = new SafeAreaEdges(SafeAreaRegions.Container)
on ContentPages in existing testsPlatform-Specific API Support
The legacy iOS/Mac Catalyst platform-specific
UseSafeArea
API continues to work as before:iOS Screenshot Changes Explained
Important Note: All iOS screenshot changes in this PR are due to test files being updated to explicitly set
SafeAreaEdges = Container
on ContentPages.Why are iOS screenshots changing?
None
(edge-to-edge), Android defaulted toContainer
(safe area padding)None
(edge-to-edge)SafeAreaEdges = Container
on test ContentPagesThis is the intended behavior - the tests are now explicitly specifying
Container
to maintain their previous appearance, whereas before they were implicitly getting different defaults on different platforms.Breaking Changes⚠️
This is an intentional breaking change to ensure platform consistency:
Impact:
Migration:
Apps that need safe area padding can use either:
Testing
Fixes
Fixes #31925
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.