Repository navigation
[net11.0] Expose safe area contract for custom views - #38039
Merged
Merged
Conversation
Allow custom views and native hosts to use MAUI's per-edge safe area model while preserving built-in compatibility behavior across iOS and Android. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo
temporarily deployed
to
copilot-pat-pool
August 31, 2026 15:58 — with
GitHub Actions
Inactive
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 38039Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 38039" |
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
kubaflo
temporarily deployed
to
copilot-pat-pool
August 31, 2026 15:58 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
August 31, 2026 15:59 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
August 31, 2026 16:01 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
August 31, 2026 16:02 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
August 31, 2026 16:03 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
Pull request overview
This PR introduces a public, per-edge safe-area contract (ISafeAreaElement) for custom/third-party views and updates MAUI’s iOS/MacCatalyst/Android platform logic to honor that contract while keeping existing built-in/legacy behaviors intact.
Changes:
- Adds public
Microsoft.Maui.ISafeAreaElementandSafeAreaElementExtensions.GetEffectiveSafeAreaEdges()and updates all Core PublicAPI baselines accordingly. - Routes iOS/MacCatalyst and Android safe-area resolution through the public contract (while preserving
ISafeAreaView2and legacyISafeAreaViewbehavior). - Adds/updates unit tests to validate the public contract and effective-edge behavior.
File summaries
| File | Description |
|---|---|
| src/Core/src/Core/ISafeAreaElement.cs | Makes ISafeAreaElement public and adds GetEffectiveSafeAreaEdges() plus internal helper extensions used by platform code. |
| src/Core/src/Handlers/View/ViewHandler.cs | Enables safe-area edge mapping on MacCatalyst as well as iOS/Android. |
| src/Core/src/Handlers/View/ViewHandler.iOS.cs | Invalidates the native safe-area subtree when SafeAreaEdges changes at runtime. |
| src/Core/src/Platform/iOS/MauiView.cs | Switches per-edge safe-area evaluation to the shared public/internal contract and adds subtree invalidation helper. |
| src/Core/src/Platform/iOS/MauiScrollView.cs | Uses shared edge-resolution logic for scroll-view safe-area decisions. |
| src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs | Aligns keyboard auto-scroll suppression with the updated safe-area edges handling. |
| src/Core/src/Platform/Android/SafeAreaExtensions.cs | Adds support for reading safe-area edges from ISafeAreaElement (including via handler.VirtualView). |
| src/Core/src/Platform/Android/MauiWindowInsetListener.cs | Treats ISafeAreaElement as an explicit safe-area opt-in for inset tracking decisions. |
| src/Controls/src/Core/SafeAreaElement.cs | Keeps default-value creation internal via an internal controller interface while preserving safe defaults. |
| src/Controls/src/Core/Layout/Layout.cs | Updates built-in controls to participate via the internal controller interface for default-value creation. |
| src/Controls/src/Core/ContentView/ContentView.cs | Same: shifts to the controller interface to keep default creation internal while enabling public reading. |
| src/Controls/src/Core/ContentPage/ContentPage.cs | Same: aligns built-in page with controller-based defaults and public contract. |
| src/Controls/src/Core/Border/Border.cs | Same: aligns built-in border with controller-based defaults and public contract. |
| src/Controls/src/Core/ScrollView/ScrollView.cs | Same: aligns built-in scroll view with controller-based defaults and public contract. |
| src/Controls/tests/Core.UnitTests/SafeAreaTests.cs | Adds tests covering custom ISafeAreaElement behavior and effective-edge semantics. |
| src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt | Records new public API surface for .NET TFMs. |
| src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt | Records new public API surface for netstandard TFMs. |
| src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt | Records new public API surface for netstandard2.0 TFMs. |
| src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt | Records new public API surface for Android TFM. |
| src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | Records new public API surface for iOS TFM. |
| src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | Records new public API surface for MacCatalyst TFM. |
| src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt | Records new public API surface for Windows TFM. |
| src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt | Records new public API surface for Tizen TFM. |
Review details
- Files reviewed: 23/23 changed files
- Comments generated: 1
- Review effort level: Lite
Comment on lines
616
to
+618
| /// <summary> | ||
| /// Called when the scroll orientation has changed to trigger proper RTL layout recalculation. | ||
| /// </summary> | ||
| /// Called when the scroll orientation has changed to trigger proper RTL layout recalculation. | ||
| /// </summary> |
jfversluis
approved these changes
Aug 31, 2026
This branch was previously deployed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Expose a focused public safe-area contract for third-party and custom views:
ISafeAreaElementpublic with its per-edgeSafeAreaEdgesconfigurationGetEffectiveSafeAreaEdges()so native hosts can read the same compatibility-resolved values used by MAUI handlersISafeAreaView2path for built-in controlsSafeAreaEdgeschanges at runtimeISafeAreaElementlayouts as explicitly opted in when Android evaluates nested recycler/scroll-view listenersThis lets a custom view define its own bindable
SafeAreaEdgesproperty and participate inContainer,None,All, andSoftInputbehavior without implementing MAUI-internal interfaces. Existing built-in defaults and legacyIgnoreSafeAreabehavior remain unchanged.This PR supersedes and replaces #37750. That PR grew to 58 files and its current CI fails during compilation because stale
StatusBarThemeentries are duplicated inPublicAPI.Unshipped.txt, preventing its platform tests from running. This replacement was developed independently from the currentnet11.0source, then compared afterward; it retains the necessary native-host resolution and runtime invalidation while avoiding the unrelated API baseline churn and broad safe-area refactor.Public API
Validation
Unit and API validation
dotnet build Microsoft.Maui.BuildTasks.slnf --no-restore -p:PublicApiType=Validate --nologo --verbosity:minimaldotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj --no-restore -p:PublicApiType=Validate --filter FullyQualifiedName~SafeAreaTests --logger "console;verbosity=minimal"iOS
dotnet build src/Core/src/Core.csproj -f net11.0-ios26.5 -p:IncludeIosTargetFrameworks=true -p:PublicApiType=Validate --no-restore --nologo --verbosity:minimalpwsh .github/scripts/BuildAndRunSandbox.ps1 -Platform ios -Configuration Debug -DeviceUdid 20F5E8A1-901C-4C42-B8AA-E41A0641E2C5TemplatedView : ISafeAreaElementtoggledNone -> Container -> Nonesafe-area-custom-view-ios.mp4
Android
dotnet build src/Core/src/Core.csproj -f net11.0-android37.0 -p:IncludeAndroidTargetFrameworks=true -p:PublicApiType=Validate --no-restore --nologo --verbosity:minimalANDROID_SERIAL=emulator-5554 pwsh .github/scripts/BuildAndRunSandbox.ps1 -Platform android -Configuration Release -DeviceUdid emulator-5554TemplatedView : ISafeAreaElementtoggledNone -> Container -> Nonesafe-area-custom-view-android.mp4
The proof-only Sandbox scenario was removed after recording; production tests remain in the change.
Issues Fixed
Fixes #37384