Repository navigation
[.NET 12] Native bottom sheets for iOS and Android - #40658
jfversluis wants to merge 5 commits into
Conversation
A page pushed with PushModalAsync (or a Shell route) presents as the platform's own bottom sheet when BottomSheet.IsEnabled is set: UISheetPresentationController on iOS/Mac Catalyst and Material's BottomSheetDialogFragment on Android. Other platforms show a regular modal. Attached properties: IsEnabled, Detents (Medium, Large, FitContent, Fraction, Height; up to three), SelectedDetent (two-way), HasDragHandle, IsDismissible and CornerRadius, with XAML type converters and iOS-specific edge-attached and scrolling-expands options. The modal stack stays in sync when the user dismisses a sheet natively (swipe, outside tap, back), including Shell routes, ModalPopping vetoes, Navigating deferrals and modals pushed meanwhile. Shell no longer loops forever when a ModalPopping handler cancels a route's modal pop. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Mac Catalyst shows the page in a window sheet, but UIKit still drew the grabber on the presenting window, where it floated over the dimmed content and moved with the selected detent. Also annotate nullable locals in the Android deferral device test. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 7 findings · ⚠️ 1 breaking change
Reviewed commit db01fee.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| #endif | ||
|
|
||
| // Asked before anything is popped: Shell would otherwise unwind a NavigationPage inside the modal first. | ||
| bool canceled = _window.OnModalPopping(modal); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - For an existing iOS Shell app with a pushed details page underneath an ordinary PageSheet modal (BottomSheet.IsEnabled is false), swiping the modal away previously fired Shell.Navigating before Window/Application.ModalPopping. This unconditional preapproval reverses that order, and PopModalAsync suppresses the later notification. Unchanged callbacks that initialize dismissal state in Navigating and consume it in ModalPopping now consume it before initialization, even when neither callback cancels. Preserve the existing order for ordinary modals behind an opt-in/opt-out and explicitly disclose the event-order change; this is separate from fixing canceled dismissals.
| if (modalPopCanceled) | ||
| { | ||
| IsPoppingModalStack = false; | ||
| break; |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - This break stops stack preparation, but its caller GoToAsync still creates and pushes target routes. With a stack root/A/M, a ModalPopping veto for modal M, and an absolute request for root/A/B/C, preparation leaves M intact. The caller then starts at currentNavStack.Count - 1 (2), skips B, and presents C above M. The canceled replacement therefore changes the visible page and produces the wrong stack. Propagate cancellation to GoToAsync so its remaining push phase also stops.
| } | ||
| } | ||
|
|
||
| if (shellNavigationParameters.DismissalStillApplies is { } dismissalStillApplies && !dismissalStillApplies()) |
There was a problem hiding this comment.
[major] Navigation & Shell - This dismissal guard is checked only before navigation starts, not after the awaits that unwind the modal stack. With a pushed route A underneath a bottom-sheet NavigationPage containing an inner details page, native dismissal targets A. PrepareCurrentStackForBeingReplaced first awaits the inner PopAsync. If another modal B is pushed during that await or from NavigationPage.Popped, the rebuilt flattened stack includes B and the loop pops B before removing the dismissed sheet. Revalidate the dismissed request before subsequent destructive pops; the added deferral tests only push B before this initial guard.
|
|
||
| _themeFillColor ??= shape.FillColor; | ||
|
|
||
| var color = page.BackgroundColor ?? (page.Background as SolidColorBrush)?.Color; |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - This chooses BackgroundColor before Background, reversing VisualElement's IView.Background precedence. A sheet with BackgroundColor=Red and Background=new SolidColorBrush(Blue) renders its page blue but its drag-handle area and rounded-corner surface red. The same mismatch occurs when BackgroundColor comes from a style and an explicit solid Background overrides it. Resolve the surface color with the same effective-background precedence as the page.
| /// <returns>The XAML form of the detent.</returns> | ||
| public override string ToString() => Kind switch | ||
| { | ||
| BottomSheetDetentKind.Fraction => (Value * 100).ToString("0.###", CultureInfo.InvariantCulture) + "%", |
There was a problem hiding this comment.
[moderate] Public API Surface Design - Fraction accepts six decimal places, but this percentage format loses one during converter round-trips: Fraction(0.123456) becomes "12.346%" and parses back as the unequal Fraction(0.12346). Restoring that value into SelectedDetent cannot select the original entry because both platforms use exact detent equality. Fraction(0.000001) even becomes "0%", which the converter rejects. Preserve four percentage decimal places so every valid fractional detent retains its identity; the added round-trip tests cover only coarser percentages.
| window.ModalPopping += (_, e) => e.Cancel = true; | ||
|
|
||
| // Shell used to retry the canceled pop forever. | ||
| var dismissal = window.ModalNavigationManager.OnPlatformModalDismissedAsync(sheet); |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - This test bypasses the cancellation-loop fix it claims to cover: OnPlatformModalDismissedAsync calls OnModalPopping first, and the veto prevents it from calling Shell.GoToAsync at all. Removing the new modalPopCanceled checks would therefore leave this test green. Add a direct Shell.GoToAsync("..") regression with a pushed page beneath a modal and a ModalPopping veto, asserting bounded completion and unchanged stacks/location, plus the same route without a veto. That exercises the original infinite-retry scenario.
| await page.Navigation.PushModalAsync(sheet); | ||
| await OnLoadedAsync(sheet.Content); | ||
|
|
||
| await AssertNativeSheetState(sheet, expectedStops: 3, expectedIndex: 0, dismissible: false); |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - This unconditional three-stop expectation fails on supported iOS 15 even when presentation is correct. ResolveSystemStops maps Fraction(0.25) and Medium to one native Medium stop, so the sheet has only Medium/Large; the iOS helper waits for Detents.Length == 3. The later Large selection likewise expects index 2 instead of 1. Use version-aware expectations and assert the two-stop iOS 15 fallback while retaining three-stop assertions for custom-detent-capable runtimes.
Apps can check it to choose a different presentation on platforms without a native bottom sheet, such as Windows, where the page is shown as a regular modal page. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
The iOS 15 test has incorrect detent expectations that cause timeouts, alongside unresolved defects in fraction round-tripping, navigation cancellation, and Android sheet background precedence.
4 open issues
What changed in this PR
Adds native bottom sheets to .NET MAUI through existing modal navigation and Shell routing, using UIKit on iOS/Mac Catalyst and Material on Android. Windows retains regular modal presentation.
Changes:
- Adds attached properties, configurable detents, XAML converters, and platform support detection.
- Integrates native sheet presentation, selection, dismissal, and modal-stack synchronization.
- Adds unit, XAML, and device tests for sheet behavior and navigation cancellation.
| File | Description |
|---|---|
| src/Controls/tests/Xaml.UnitTests/BottomSheetProperties.xaml.cs | Tests attached-property parsing and binding across XAML inflators. |
| src/Controls/tests/Xaml.UnitTests/BottomSheetProperties.xaml | Defines sheet properties for XAML tests. |
| src/Controls/tests/DeviceTests/Elements/Modal/ModalTests.BottomSheet.iOS.cs | Adds UIKit presentation and interaction test helpers. |
| src/Controls/tests/DeviceTests/Elements/Modal/ModalTests.BottomSheet.cs | Tests presentation, dismissal, selection, and back handling. |
| src/Controls/tests/DeviceTests/Elements/Modal/ModalTests.BottomSheet.Android.cs | Adds Material helpers and deferred-dismissal coverage. |
| src/Controls/tests/Core.UnitTests/ShellModalTests.cs | Tests sheet routing and canceled or deferred dismissals. |
| src/Controls/tests/Core.UnitTests/ModalNavigationPlatformTests.cs | Tests platform-dismissal synchronization and restoration. |
| src/Controls/tests/Core.UnitTests/BottomSheetTests.cs | Tests detent validation, conversion, and resolution. |
| src/Controls/src/Core/Shell/ShellSection.cs | Integrates sheet routes and detects canceled modal pops. |
| src/Controls/src/Core/Shell/ShellNavigationParameters.cs | Carries a guard for stale dismissal navigation. |
| src/Controls/src/Core/Shell/ShellNavigationManager.cs | Checks dismissal validity after navigation deferrals. |
| src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt | Records the new .NET Standard API surface. |
| src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt | Records the new .NET API surface. |
| src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt | Records the new Windows API surface. |
| src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | Records the new Mac Catalyst API surface. |
| src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt | Records the new iOS API surface. |
| src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt | Records the new Android API surface. |
| src/Controls/src/Core/PlatformConfiguration/iOSSpecific/Page.cs | Adds compact-height and scrolling preferences. |
| src/Controls/src/Core/Platform/ModalNavigationManager/ModalNavigationManager.cs | Reconciles native dismissals with modal navigation. |
| src/Controls/src/Core/Platform/ModalNavigationManager/ModalNavigationManager.BottomSheet.Android.cs | Implements Material sheet presentation and behavior. |
| src/Controls/src/Core/Platform/ModalNavigationManager/ModalNavigationManager.Android.cs | Tracks sheet fragments and manages their lifecycle. |
| src/Controls/src/Core/Platform/ModalNavigationManager/ModalDialogEvents.Android.cs | Shares modal input-event forwarding. |
| src/Controls/src/Core/Platform/iOS/ControlsModalWrapper.cs | Connects UIKit sheet configuration and delegate callbacks. |
| src/Controls/src/Core/Platform/iOS/BottomSheetPresentation.cs | Maps detents and properties to UIKit sheets. |
| src/Controls/src/Core/Page/Page.cs | Consumes back presses for non-dismissible sheets. |
| src/Controls/src/Core/BottomSheet/BottomSheetDetentTypeConverter.cs | Parses individual detents and XAML detent lists. |
| src/Controls/src/Core/BottomSheet/BottomSheetDetentResolver.cs | Resolves, orders, and merges resting heights. |
| src/Controls/src/Core/BottomSheet/BottomSheetDetentKind.cs | Defines supported detent kinds. |
| src/Controls/src/Core/BottomSheet/BottomSheetDetent.cs | Defines detent values, equality, and serialization. |
| src/Controls/src/Core/BottomSheet/BottomSheet.cs | Exposes sheet properties and support detection. |
| src/Controls/src/Core/Animations/ModalPageTransitions.iOS.cs | Preserves native sheet transitions. |
Review effort: Balanced
| var wrapper = GetSheetWrapper(sheet); | ||
| var sheetController = wrapper.SheetPresentationController!; | ||
|
|
||
| await AssertEventually(() => sheetController.Detents.Length == expectedStops); |
| /// <returns>The XAML form of the detent.</returns> | ||
| public override string ToString() => Kind switch | ||
| { | ||
| BottomSheetDetentKind.Fraction => (Value * 100).ToString("0.###", CultureInfo.InvariantCulture) + "%", |
|
|
||
| _themeFillColor ??= shape.FillColor; | ||
|
|
||
| var color = page.BackgroundColor ?? (page.Background as SolidColorBrush)?.Color; |
| if (modalPopCanceled) | ||
| { | ||
| IsPoppingModalStack = false; | ||
| break; |
There was a problem hiding this comment.
Expert Review — 10 findings · ⚠️ 1 breaking change
Reviewed commit 12e80e5.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
Previously reported findings were not duplicated.
| #endif | ||
|
|
||
| // Asked before anything is popped: Shell would otherwise unwind a NavigationPage inside the modal first. | ||
| bool canceled = _window.OnModalPopping(modal); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - In an existing iOS Shell app with a pushed details page beneath an ordinary PageSheet modal (BottomSheet.IsEnabled is false), swiping the modal away previously raised Shell.Navigating before Window/Application.ModalPopping. ControlsModalWrapper.DidDismiss now enters this unconditional preapproval first, reversing that order; PopModalAsync suppresses the later ModalPopping notification. Unchanged callbacks that initialize dismissal state in Navigating and consume it in ModalPopping now consume it before initialization, even when neither callback cancels. Preserve the existing order for ordinary modals through an explicit opt-in/opt-out and disclose the event-order change. This is separate from fixing canceled dismissals.
| if (modalPopCanceled) | ||
| { | ||
| IsPoppingModalStack = false; | ||
| break; |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - This break stops stack preparation, but its caller GoToAsync still creates and pushes target routes. With stack root/A/M, a ModalPopping veto for modal M, and an absolute request for root/A/B/C, preparation leaves M intact. GoToAsync then starts at currentNavStack.Count - 1 (2), skips B, and presents C above M. The canceled replacement therefore changes the visible page and produces the wrong stack. Propagate cancellation to the caller so the remaining push phase also stops.
| } | ||
| } | ||
|
|
||
| if (shellNavigationParameters.DismissalStillApplies is { } dismissalStillApplies && !dismissalStillApplies()) |
There was a problem hiding this comment.
[major] Navigation & Shell - Native dismissal supplies a page to OnPlatformModalDismissedAsync, which builds an absolute target URI through GetNavigationParameters and passes it to GoToAsync. This guard checks that dismissal only before navigation starts, not after awaits that unwind the modal stack. With route A beneath a bottom-sheet NavigationPage containing a details page, preparation first awaits the inner PopAsync. If app code pushes modal B during that await or from NavigationPage.Popped, the rebuilt flattened stack includes B and the next PopModalAsync removes B before the dismissed sheet. Revalidate the dismissed request before subsequent destructive pops; the added deferral tests push B before this initial guard, not during stack unwinding.
|
|
||
| _themeFillColor ??= shape.FillColor; | ||
|
|
||
| var color = page.BackgroundColor ?? (page.Background as SolidColorBrush)?.Color; |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - This chooses BackgroundColor before Background, reversing VisualElement's IView.Background precedence. An Android sheet with BackgroundColor=Red and Background=new SolidColorBrush(Blue) renders its page blue but its drag-handle area and rounded-corner surface red. The same mismatch occurs when a styled BackgroundColor is overridden by an explicit solid Background. Resolve the surface color from the page's effective background.
| behavior.SkipCollapsed = false; | ||
| behavior.PeekHeight = heights[0]; | ||
| behavior.ExpandedOffset = Math.Max(topInset, _parentHeight - sheetHeight); | ||
| behavior.HalfExpandedRatio = Math.Clamp((float)(heights[1] + bottomInset) / _parentHeight, 0.01f, 0.99f); |
There was a problem hiding this comment.
[moderate] Logic and Correctness Verification - Clamping the half-expanded ratio to 0.99 collapses distinct valid detents near full height. For a 1000-pixel parent with density 1 and no deducted system insets, Fraction(0.99), Fraction(0.995), and Large resolve to 990, 995, and 1000 pixels. This sets PeekHeight=990 but clamps the middle ratio from 0.995 to 0.99, so the half-expanded position is also 990 pixels instead of 995. Selecting the middle detent cannot reach its declared height. Preserve valid ratios inside the native exclusive 0-to-1 range rather than imposing a 1%-99% range; the tests assert state names but not these heights.
|
|
||
| // Shell used to retry the canceled pop forever. | ||
| var dismissal = window.ModalNavigationManager.OnPlatformModalDismissedAsync(sheet); | ||
| Assert.Same(dismissal, await Task.WhenAny(dismissal, Task.Delay(5000))); |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - This test bypasses the cancellation-loop fix it claims to cover: OnPlatformModalDismissedAsync calls OnModalPopping first, and the veto prevents it from calling Shell.GoToAsync at all. Removing the new modalPopCanceled checks would therefore leave this test green. Add a direct Shell.GoToAsync("..") regression with a pushed page beneath a modal and a ModalPopping veto, asserting bounded completion and unchanged stacks/location, plus the same route without a veto. That exercises the original infinite-retry scenario.
| await OnLoadedAsync(sheet.Content); | ||
|
|
||
| Assert.True(((IWindow)window).BackButtonClicked()); | ||
| await Task.Delay(100); |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - Calling IWindow.BackButtonClicked directly bypasses the Android sheet dialog's OnBackPressedDispatcher and BackCallback. Removing the new callback registration or making HandleOnBackPressed a no-op leaves this test unchanged, although a real system back press would no longer reach MAUI navigation. Add Android coverage through the showing dialog's dispatcher, including a NavigationPage with an inner details page that must pop without dismissing the sheet, and a non-dismissible sheet that must remain open.
| if (double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out var height)) | ||
| { | ||
| // A bare value below 1 is almost certainly meant as a fraction, which is ambiguous with a height. | ||
| if (!(height >= 1) || double.IsInfinity(height)) |
There was a problem hiding this comment.
[moderate] Public API Surface Design - The public Height factory accepts positive heights below 1, but the converter rejects their advertised XAML representation. Height(0.5) is valid and ConvertToInvariantString produces "0.5", while ConvertFromInvariantString of that same string throws FormatException. The collection converter inherits this failure, so serializing and restoring a valid Detents list containing this value also fails. Align the factory and converter value domains, and cover a factory-created sub-unit height in the round-trip tests.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Selected Tests
🧪 Test selection — click to expand
🧪 UI tests —
|
| Platform | Categories |
|---|---|
| Android | Lifecycle, Navigation, Page, Shell1, Shell2, Material3 |
| iOS | Lifecycle, Navigation, Page, Shell1, Shell2 |
| MacCatalyst | Lifecycle, Navigation, Page, Shell1, Shell2 |
| Windows | Lifecycle, Navigation, Page, Shell1, Shell2 |
🧪 Device tests — Controls.Lifecycle, Controls.Modal, Controls.NavigationPage, Controls.Page +2 on Android, iOS, MacCatalyst, Windows
❌ Could not queue maui-pr-devicetests: This PR has merge conflicts with main, so there is no test-merge commit to build. Resolve the conflicts, then comment /review run-tests again.
GPT-6.2 Sol: Run targeted Controls device tests for native bottom sheets, Windows modal fallback, Shell routing, and modal transitions.
MAI Code 2: Run modal, navigation, Shell, lifecycle, page, and transition device tests for the new bottom-sheet presentation on every platform.
🧪 Running — 6 categories on Android, iOS, MacCatalyst, Windows
| Platform | Categories |
|---|---|
| Android | Controls.Lifecycle, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Shell |
| iOS | Controls.Lifecycle, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Shell |
| MacCatalyst | Controls.Lifecycle, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Shell |
| Windows | Controls.Lifecycle, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Shell |
⏭️ Skipped — what neither suite runs
UI tests — 71 categories, 0 platforms
Categories not run: Accessibility, ActionSheet, ActivityIndicator, Animation, AppLinks, Border, BoxView, Brush, Button, CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7, Cells, CheckBox, ContextActions, CustomRenderers, DatePicker, Dispatcher, DisplayAlert, DisplayPrompt, DragAndDrop, Entry, Editor, Effects, Essentials, FlyoutPage, Focus, Fonts, Frame, Gestures, GraphicsView, Image, ImageButton, IndicatorView, InputTransparent, IsEnabled, IsVisible, Label, Layout, ManualReview, Maps, Performance, Picker, ProgressBar, RadioButton, RefreshView, SafeAreaEdges, Shadow, ScrollView, SearchBar, Shape, Slider, SoftInput, Stepper, Switch, SwipeView, TabbedPage, TableView, TimePicker, TitleView, ToolbarItem, Triggers, ViewBaseTests, VisualStateManager, Window, WebView
Each skipped platform and category is listed as a maui-pr-uitests (skipped) … status on this commit. Use /azp run maui-pr-uitests for the full suite.
Device tests — 99 categories, 0 platforms
Categories not run: Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay, Graphics, Essentials, BlazorWebView
Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.
🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)
UI tests
Each model chose independently; every test that runs was selected by at least one of them.
| Platform | GPT-6.2 Sol | MAI Code 2 |
|---|---|---|
| Android | Navigation, Shell1, Shell2, Material3 |
Navigation, Page, Lifecycle, Shell1, Shell2 |
| iOS | Navigation, Shell1, Shell2 |
Navigation, Page, Lifecycle, Shell1, Shell2 |
| MacCatalyst | Navigation, Shell1, Shell2 |
Navigation, Page, Lifecycle, Shell1, Shell2 |
| Windows | Navigation, Shell1, Shell2 |
Navigation, Page, Lifecycle, Shell1, Shell2 |
GPT-6.2 Sol — Run Navigation and Shell UI tests on all four platforms for shared modal routing, plus Material3 on Android for bottom-sheet styling.
- Shared ModalNavigationManager and ShellSection change modal pops and routing, including Windows fallback.
- Android bottom sheets use a Material3 drag-handle style.
- No unrelated controls or shared UI test infrastructure changed.
MAI Code 2 — Native bottom-sheet modal presentation plus shared modal and Shell navigation changes; run navigation, page, lifecycle, and Shell UI coverage on all platforms.
- Controls modal presentation and back handling change in shared code, with native sheet implementations on Android, iOS, and Mac Catalyst;
Navigation,Page, andLifecyclecover stack synchronization, presentation, dismissal, and lifecycle behavior. - Shell routing and modal-stack handling are changed, so include
Shellon all supported platforms. - iOS modal transition suppression also applies to Mac Catalyst; Windows runs the new feature's regular-modal fallback and shares the navigation changes.
- Unrelated control categories and a full run are omitted because the change is confined to modal/page/Shell presentation rather than base layout or app startup.
Device tests
Each model chose independently; every test that runs was selected by at least one of them.
| Platform | GPT-6.2 Sol | MAI Code 2 |
|---|---|---|
| Android | Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.PageTransitions |
Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.Lifecycle, Controls.Page, Controls.PageTransitions |
| iOS | Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.PageTransitions |
Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.Lifecycle, Controls.Page, Controls.PageTransitions |
| MacCatalyst | Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.PageTransitions |
Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.Lifecycle, Controls.Page, Controls.PageTransitions |
| Windows | Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.PageTransitions |
Controls.Modal, Controls.NavigationPage, Controls.Shell, Controls.Lifecycle, Controls.Page, Controls.PageTransitions |
GPT-6.2 Sol — Run targeted Controls device tests for native bottom sheets, Windows modal fallback, Shell routing, and modal transitions.
- ModalTests.BottomSheet covers native sheets and Windows modal fallback.
- ModalNavigationManager and ShellSection change stack and cancellation behavior.
- Android and iOS sheet paths change modal transitions; no Core handlers changed.
MAI Code 2 — Run modal, navigation, Shell, lifecycle, page, and transition device tests for the new bottom-sheet presentation on every platform.
- New device tests exercise native Android/iOS/Catalyst bottom-sheet state, user dismissal, detents, rapid push/pop, and the modal stack, requiring
Controls.Modal. - Shared modal and Shell navigation logic changes affect
Controls.NavigationPageandControls.Shell, including modal pages embedded in navigation and routed sheets. - Modal user dismissal and Page back-button handling alter presentation lifecycle, so include
Controls.LifecycleandControls.Page. - iOS modal transition behavior changes for sheets, requiring
Controls.PageTransitionson iOS and Mac Catalyst; Windows is retained for shared fallback and synchronization coverage, without widening to all Controls/Core tests.
Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.
There was a problem hiding this comment.
Expert Review — 10 findings · ⚠️ 1 breaking change
Reviewed commit 12e80e5.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
| #endif | ||
|
|
||
| // Asked before anything is popped: Shell would otherwise unwind a NavigationPage inside the modal first. | ||
| bool canceled = _window.OnModalPopping(modal); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - In an existing iOS Shell app with a pushed details page beneath an ordinary PageSheet modal (BottomSheet.IsEnabled is false), swiping the modal away previously raised Shell.Navigating before Window/Application.ModalPopping. ControlsModalWrapper.DidDismiss now enters this unconditional preapproval first, reversing that order; PopModalAsync suppresses the later ModalPopping notification. Unchanged callbacks that initialize dismissal state in Navigating and consume it in ModalPopping now consume it before initialization, even when neither callback cancels. Provide an opt-out preserving the ordinary-modal event order and explicitly disclose the reversal in a breaking-change/release-note callout. The narrative describes the shared dismissal path but not this event-order change.
| if (modalPopCanceled) | ||
| { | ||
| IsPoppingModalStack = false; | ||
| break; |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - This break stops stack preparation, but its caller GoToAsync still constructs and pushes replacement routes. With stack root/A/M, a ModalPopping veto for modal M, and an absolute replacement targeting root/A/B/C, preparation leaves M intact. GoToAsync then starts at currentNavStack.Count - 1 (2), skips B, and presents C above M. The canceled replacement changes the visible page and produces the wrong stack. Propagate cancellation to the caller so its remaining push phase also stops.
| } | ||
| } | ||
|
|
||
| if (shellNavigationParameters.DismissalStillApplies is { } dismissalStillApplies && !dismissalStillApplies()) |
There was a problem hiding this comment.
[major] Navigation & Shell - Native dismissal supplies the dismissed page to OnPlatformModalDismissedAsync, which builds an absolute target URI through GetNavigationParameters and passes it to GoToAsync. This guard checks validity only before stack unwinding. With route A beneath a bottom-sheet NavigationPage containing a details page, preparation first awaits the inner PopAsync. If NavigationPage.Popped pushes modal B through window.Navigation.PushModalAsync, the rebuilt flattened stack includes B and the next iteration pops B before the dismissed sheet. Revalidate DismissalStillApplies after awaits and before subsequent destructive pops. The added deferral tests push B before this guard, not during unwinding.
|
|
||
| _themeFillColor ??= shape.FillColor; | ||
|
|
||
| var color = page.BackgroundColor ?? (page.Background as SolidColorBrush)?.Color; |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - This chooses BackgroundColor before Background, reversing VisualElement's shared IView.Background precedence. An Android sheet with BackgroundColor=Red and Background=new SolidColorBrush(Blue) renders its page blue but its drag-handle area and rounded-corner surface red. The same mismatch occurs when a styled BackgroundColor is overridden by an explicit solid Background. Resolve the surface color from the page's effective background instead of duplicating property precedence in the platform fragment.
| behavior.SkipCollapsed = false; | ||
| behavior.PeekHeight = heights[0]; | ||
| behavior.ExpandedOffset = Math.Max(topInset, _parentHeight - sheetHeight); | ||
| behavior.HalfExpandedRatio = Math.Clamp((float)(heights[1] + bottomInset) / _parentHeight, 0.01f, 0.99f); |
There was a problem hiding this comment.
[moderate] Logic and Correctness Verification - The 0.01-to-0.99 clamp changes valid middle-detent heights. For a 1000-pixel parent at density 1 with no deducted system insets, Fraction(0.99), Fraction(0.995), and Large resolve to distinct heights 990, 995, and 1000. PeekHeight becomes 990, but the middle ratio is clamped from 0.995 to 0.99, placing the half-expanded stop at approximately 990 instead of 995. Selecting the middle detent cannot reach its declared height. Preserve valid ratios within Material's exclusive 0-to-1 domain; the tests assert state names rather than these heights.
| /// <returns>The XAML form of the detent.</returns> | ||
| public override string ToString() => Kind switch | ||
| { | ||
| BottomSheetDetentKind.Fraction => (Value * 100).ToString("0.###", CultureInfo.InvariantCulture) + "%", |
There was a problem hiding this comment.
[moderate] Public API Surface Design - Fraction accepts six decimal places, but its percentage format loses detent identity during converter round-trips: Fraction(0.123456) becomes "12.346%" and parses back as the unequal Fraction(0.12346). Restoring that value into SelectedDetent cannot select the original entry because both platform presenters use exact detent equality. Fraction(0.000001) even becomes "0%", which the converter rejects. Preserve at least four percentage decimal places and cover factory-created precision and lower-bound values; the added round-trip fixtures contain only coarser percentages.
| if (double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out var height)) | ||
| { | ||
| // A bare value below 1 is almost certainly meant as a fraction, which is ambiguous with a height. | ||
| if (!(height >= 1) || double.IsInfinity(height)) |
There was a problem hiding this comment.
[moderate] Public API Surface Design - The public Height factory accepts positive heights below 1, but the converter rejects their advertised XAML representation. Height(0.5) is valid and ConvertToInvariantString produces "0.5", while converting that string back throws FormatException here. The collection converter inherits the same failure when serializing and restoring a valid Detents list. Align the factory and converter value domains, and cover a factory-created sub-unit height in the round-trip tests.
| await page.Navigation.PushModalAsync(sheet); | ||
| await OnLoadedAsync(sheet.Content); | ||
|
|
||
| await AssertNativeSheetState(sheet, expectedStops: 3, expectedIndex: 0, dismissible: false); |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - This unconditional three-stop expectation times out on supported iOS 15 even when presentation is correct. ResolveSystemStops maps Fraction(0.25) and Medium to one native Medium stop, leaving only Medium/Large, while the iOS helper waits for Detents.Length == 3. The subsequent Large selection likewise expects index 2 instead of 1. Use version-aware count and index expectations that assert the two-stop fallback on iOS 15 while retaining three-stop assertions on custom-detent-capable runtimes.
| window.ModalPopping += (_, e) => e.Cancel = true; | ||
|
|
||
| // Shell used to retry the canceled pop forever. | ||
| var dismissal = window.ModalNavigationManager.OnPlatformModalDismissedAsync(sheet); |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - This test bypasses the cancellation-loop fix it claims to cover: OnPlatformModalDismissedAsync calls OnModalPopping first, and the veto prevents Shell.GoToAsync from running. Removing the new modalPopCanceled checks would therefore leave this test unchanged. Add a direct Shell.GoToAsync("..") regression with a pushed page beneath a modal and a ModalPopping veto, asserting bounded completion and unchanged stacks/location, plus the same route without a veto. Also cover an absolute multi-segment replacement after a veto so the caller's push phase cannot silently continue.
| await page.Navigation.PushModalAsync(sheet); | ||
| await OnLoadedAsync(sheet.Content); | ||
|
|
||
| Assert.True(((IWindow)window).BackButtonClicked()); |
There was a problem hiding this comment.
[moderate] Regression Prevention and Test Coverage - Calling IWindow.BackButtonClicked directly bypasses the Android sheet dialog's OnBackPressedDispatcher and BackCallback. Removing the callback registration or making HandleOnBackPressed a no-op leaves this test unchanged although system back would no longer reach MAUI navigation. Exercise the showing dialog's dispatcher with dismissible and non-dismissible sheets, plus a NavigationPage containing a details page that must pop without dismissing the sheet.
…0755) <!-- Please let the below note in for people that find this PR --> > [!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](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- Open .NET 11 fix PRs against net11 for review; target main for next-major features. After approval, a maintainer manually retargets the fix PR to the active inflight branch and merges it directly there. Do not merge individual fixes into net11. Bots must not retarget or merge. Candidate integration into net11 and release/* changes are separate, explicitly coordinated release work. --> ### Target Branch | This PR is for | Initial base | | --- | --- | | New features, API changes, or .NET 12 work (including .NET 12 fixes) | `main` | | .NET 11 servicing fixes | `net11`, for review | | Older servicing, release integration, infrastructure, or documentation | The branch designated for that work | - [x] I selected the applicable base branch using the [contribution guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting). For .NET 11 fixes, only a maintainer retargets the approved PR to the active inflight lane and merges it after CI validates that final base. Do not merge individual fixes directly into `net11`; agents must not retarget or merge. ### Description of Change Fix the deterministic `PageTransitionsTests` failures on `main`, including the product defects exposed once the More controller actually runs the transition. #### Product fixes - **Programmatically selected overflow tabs never installed the More navigation delegate.** UIKit reports the selected section's own controller, not `MoreNavigationController`, even though it displays that section inside More. Both Shell implementations now install their existing delegate for overflow sections when there are more than five tabs. This enables the custom animator, completion tracking, and shared-element flights. - **The compatibility renderer popped the wrong native stack.** Its pop-to-root operation now targets the overflow section's root on the active More controller and completes through the same transition-aware path as a single pop. It also reads the active controller's top page when recording an unanimated push, so a later pop reverses `None` instead of the page's configured Fade. - **The managed transition-coordinator binding rejects a null animation callback.** Supply a no-op animation callback while registering completion. Once the missing More delegate was fixed, the original callback produced `ArgumentNullException: animate` from `UIViewControllerTransitionCoordinatorWrapper.AnimateAlongsideTransition`. Native/default More navigation still completes immediately; only custom page transitions wait for their animation. #### Corrections to provably invalid test setup - `WindowHandlerStub` presents a workspace inside the runner's window; it never replaces `UIWindow.RootViewController`. Root-replacement tests now use a separate real window with the production content mapper. Their snapshot probe checks UIKit's native replicant class instead of the CLR `UIView` wrapper name. - `Window.PropertyChanged` runs **before** native content mapping. Install the root's own animation after the assignment, assert that it exists, and finish the replacement without detaching the root. Detaching an outgoing root lets UIKit remove its animations independently of MAUI's cleanup, invalidating the original assertion. - The destination may not have a handler immediately after `PushAsync` starts. Wait for its content to load before reading native visibility, and use a short asynchronous delay when polling so the platform animation loop can run. The original Android test throws in `NativeShown` before it can inspect a flight. - More navigation intentionally completes immediately for an unanimated push. Wait for the pushed content to load before issuing the next push/pop-to-root; otherwise UIKit has not yet finished presenting that controller. #### Which landing introduced this? The faulty transition code and tests came from #40537 (`f7d3fc1c99`), not the storyboard landing #40536 (`c1f549fd52`). Comparing those commits for all six files changed here produces an **empty diff**. The tests do not use storyboard animation holds. #40537's recorded checks include `maui-pr` but no `maui-pr-devicetests` check, so its successful build was not evidence that these device tests passed. The supplied main-branch CI window was last green at [1699752](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1699752) (`eeda7f80ed`), with the failures present from [1699985](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1699985) (`c1f549fd52`) onward, including [1703407](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1703407). Before implementation, searched open and recently merged PRs across all bases, including `release/*`, `inflight/*`, and `candidate/*`. Inspected #40658 (bottom-sheet/modal transitions), #40344 (tab reselection), #40656 (TabbedPage lifecycle), #40696 (queued animation cancellation), and #40710 (zero-length tweens); none contains these fixes. #### Local causal validation All counts below are **passed / failed**, read from fresh XHarness XML with exact-class isolation verified. Each platform was measured on original sources, with the correction, with the correction reverted, and with it restored. No physical devices were used. | Phase | iOS 27 simulator | Mac Catalyst | Android API 33 emulator | | --- | --- | --- | --- | | Original baseline | 18 / 6 | 18 / 6 | 12 / 1 | | Fixed | 24 / 0 | 24 / 0 | 13 / 0 | | Reverted | 18 / 6 | 18 / 6 | 12 / 1 | | Restored | 24 / 0 | 24 / 0 | 13 / 0 | The reverted Apple failures are the two root tests and both variants of the More navigation/shared-element tests. Android reproduces the destination-handler `NullReferenceException`. The Helix Mac Catalyst opacity timeout did **not** reproduce locally; that case passed locally before and after the correction. Final validation additionally passed **24 / 0 on an iOS 18.5 simulator**. Commands below were run from an isolated worktree based on `main` at `6d74c1c0d9`. `.dotnet` contains the SDK pinned by `global.json` (`12.0.100-alpha.1.26523.103`); Xcode is 27.2. ```bash export PATH="$PWD/.dotnet:$PATH" export DOTNET_ROOT="$PWD/.dotnet" export TMPDIR="$PWD/artifacts/transition-evidence/scratch" export DOTNET_CLI_USE_MSBUILD_SERVER=0 export MSBUILDDISABLENODEREUSE=1 export DOTNET_ROLL_FORWARD=Major export HEADLESS=true ``` Preparation — all succeeded: ```bash dotnet build src/DotNet/DotNet.csproj -p:InstallDotNet=false -p:TreatWarningsAsErrors=false -v:minimal dotnet workload install ios maccatalyst --skip-manifest-update --verbosity minimal dotnet build Microsoft.Maui.BuildTasks.slnf -p:TreatWarningsAsErrors=false --disable-build-servers -v:minimal dotnet tool restore ``` iOS causal runs — original/reverted failed **18/6**; fixed/restored passed **24/0**: ```bash pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -iOSVersion 27 -TestFilter 'Category=PageTransitions' -IncludeClasses Microsoft.Maui.DeviceTests.PageTransitionsTests -SkipXcodeVersionCheck -Timeout 00:10:00 -Rebuild ``` Mac Catalyst causal runs — original/reverted failed **18/6**; fixed/restored passed **24/0**: ```bash pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform maccatalyst -TestFilter 'Category=PageTransitions' -IncludeClasses Microsoft.Maui.DeviceTests.PageTransitionsTests -SkipXcodeVersionCheck -Timeout 00:10:00 -Rebuild ``` Android causal runs — original/reverted failed **12/1**; fixed/restored passed **13/0**: ```bash export EmbedAssembliesIntoApk=true pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform android -TestFilter 'Category=PageTransitions' -IncludeClasses Microsoft.Maui.DeviceTests.PageTransitionsTests -Timeout 00:10:00 -Rebuild ``` The runner selected `emulator-5556` and passed `--instrumentation com.microsoft.maui.controls.devicetests.TestInstrumentation`. A separate read-only API 33 emulator was used after another emulator's unauthorized ADB transport prevented the initial attempt from running tests. iOS 18.5 final compatibility check — passed **24/0**: ```bash pwsh .github/skills/run-device-tests/scripts/Run-DeviceTests.ps1 -Project Controls -Platform ios -iOSVersion 18.5 -TestFilter 'Category=PageTransitions' -IncludeClasses Microsoft.Maui.DeviceTests.PageTransitionsTests -SkipXcodeVersionCheck -Timeout 00:10:00 ``` Formatting/checks — passed, with workspace-loading warnings from the formatter: ```bash dotnet format whitespace Microsoft.Maui.sln --no-restore --include src/Controls/tests/DeviceTests/Elements/PageTransitions/PageTransitionsTests.cs src/Controls/tests/DeviceTests/Elements/PageTransitions/PageTransitionsTests.iOS.cs --verify-no-changes git diff --check ``` The full repository formatter was also attempted; it emitted unrelated analyzer edits and multi-target conflict markers. Those edits were discarded, and the surgical patch was rebuilt and retested. No unrun CI check is represented as passing. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> Deterministic main-branch `maui-pr-devicetests` failures described above; tracked here by the linked failing builds rather than an unrelated issue number. ### Let AI finish this PR - [ ] **Let the MAUI agent address review feedback and fix remaining issues on this PR.** Maintainers still decide whether it is merged. For PRs from forks, the agent opens a follow-up PR that keeps your commits. <!-- Verify the target branch follows the release workflow in docs/ReleaseBranchWorkflow.md. Infrastructure and documentation changes should target the branch where they apply. --> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Merged by MAUI Autopilot to resolve merge conflicts.
Merged by MAUI Autopilot to resolve merge conflicts.
| await AssertNativeSheetState(sheet, expectedStops: 3, expectedIndex: 0, dismissible: false); | ||
|
|
||
| BottomSheet.SetSelectedDetent(sheet, BottomSheetDetent.Large); | ||
| await AssertNativeSheetState(sheet, expectedStops: 3, expectedIndex: 2, dismissible: false); |
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved navigation and modal-lifecycle bugs can push pages after cancellation, repeat dismissal confirmations, and retain stale Android handlers, while incorrect iOS 15 test expectations cause timeouts.
8 open issues
Capture and detach the presentation handler during release · New Consume modal approval only for the matching modal · New iOS 15 test expects detents that collapse to the same stop Avoid clamping distinct detents to the same native position · New Make native stop assertions account for the iOS 15 fallback Canceled modal pop still pushes replacement pages Sheet surface ignores the page's solid background brush Percentage format loses precision and rejects the smallest fraction
Review effort: Balanced
| if (!_navigationRootManager.Connect(_modal, modalContext)) | ||
| throw new InvalidOperationException("A modal navigation root must be initialized synchronously."); | ||
|
|
||
| _connectedHandler = _modal.Handler; |
| if (_window.OnModalPopping(modal)) | ||
| // A modal the user dismissed on the platform was already allowed to pop. | ||
| bool approved = ReferenceEquals(_approvedModalPop, modal); | ||
| _approvedModalPop = null; |
| behavior.SkipCollapsed = false; | ||
| behavior.PeekHeight = heights[0]; | ||
| behavior.ExpandedOffset = Math.Max(topInset, _parentHeight - sheetHeight); | ||
| behavior.HalfExpandedRatio = Math.Clamp((float)(heights[1] + bottomInset) / _parentHeight, 0.01f, 0.99f); |
There was a problem hiding this comment.
Expert Review — 10 findings · ⚠️ 1 breaking change
Reviewed commit 26f3b54.
Warning
Existing apps would look or behave differently without opting in. See the Behavioral Change Disclosure findings at:
See inline comments for details.
Previously reported findings were not duplicated.
| #endif | ||
|
|
||
| // Asked before anything is popped: Shell would otherwise unwind a NavigationPage inside the modal first. | ||
| bool canceled = _window.OnModalPopping(modal); |
There was a problem hiding this comment.
[major] Behavioral Change Disclosure - In an existing iOS Shell app with a pushed details page beneath an ordinary PageSheet modal (BottomSheet.IsEnabled=false), swiping the modal away previously raised Shell.Navigating before Window/Application.ModalPopping. ControlsModalWrapper.DidDismiss now enters this unconditional preapproval first, reversing that order; PopModalAsync suppresses the later notification. Unchanged callbacks that initialize dismissal state in Navigating and consume it in ModalPopping now consume it before initialization, even when neither callback cancels. Provide an explicit compatibility opt-in/opt-out preserving the ordinary-modal event order and disclose the reversal. The narrative describes the shared dismissal path but not this event-order change; this is separate from fixing broken cancellation.
| if (modalPopCanceled) | ||
| { | ||
| IsPoppingModalStack = false; | ||
| break; |
There was a problem hiding this comment.
[major] Logic and Correctness Verification - This break stops stack preparation after a ModalPopping veto, but its caller GoToAsync still constructs and pushes replacement routes. With stack root/A/M, a veto for modal M, and an absolute replacement targeting root/A/B/C, preparation leaves M intact. GoToAsync then starts at currentNavStack.Count - 1 (2), skips B, and presents C above M. The canceled replacement changes the visible page and produces the wrong stack. Propagate cancellation to the caller so the remaining push phase also stops.
| } | ||
| } | ||
|
|
||
| if (shellNavigationParameters.DismissalStillApplies is { } dismissalStillApplies && !dismissalStillApplies()) |
There was a problem hiding this comment.
[major] Navigation & Shell - Native dismissal builds an absolute target URI, but DismissalStillApplies is checked only before stack unwinding. With route A beneath a bottom-sheet NavigationPage containing a details page, PrepareCurrentStackForBeingReplaced first awaits the inner PopAsync. If NavigationPage.Popped pushes modal B through window.Navigation.PushModalAsync, the rebuilt flattened stack includes B and the next iteration pops B before the dismissed sheet. Revalidate the dismissed request after awaits and before subsequent destructive pops. The added deferral tests push B before this guard, not during unwinding.
| /// <returns>The XAML form of the detent.</returns> | ||
| public override string ToString() => Kind switch | ||
| { | ||
| BottomSheetDetentKind.Fraction => (Value * 100).ToString("0.###", CultureInfo.InvariantCulture) + "%", |
There was a problem hiding this comment.
[moderate] Public API Surface Design - Fraction accepts six decimal places, but its percentage format loses detent identity during converter round-trips: Fraction(0.123456) becomes "12.346%" and parses back as the unequal Fraction(0.12346). Restoring that value into SelectedDetent cannot select the original entry because both presenters use exact detent equality. Fraction(0.000001) even becomes "0%", which the converter rejects. Preserve at least four percentage decimal places and cover factory-created precision and lower-bound values; the added round-trip fixtures contain only coarser percentages.
| behavior.SkipCollapsed = false; | ||
| behavior.PeekHeight = heights[0]; | ||
| behavior.ExpandedOffset = Math.Max(topInset, _parentHeight - sheetHeight); | ||
| behavior.HalfExpandedRatio = Math.Clamp((float)(heights[1] + bottomInset) / _parentHeight, 0.01f, 0.99f); |
There was a problem hiding this comment.
[moderate] Logic and Correctness Verification - The 0.01-to-0.99 clamp changes valid middle-detent heights. For a 1000-pixel parent at density 1 without deducted system insets, Fraction(0.99), Fraction(0.995), and Large resolve to distinct heights 990, 995, and 1000. PeekHeight becomes 990, but the middle ratio is clamped from 0.995 to 0.99, putting the half-expanded stop at approximately 990 instead of 995. Selecting the middle detent cannot reach its declared height. Preserve ratios within Material's exclusive 0-to-1 range; the tests assert state names rather than these heights.


Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
12e80e5b4d975f61272d668fb715db23036c2dbb↑ Modal device tests: iOS 27 250/250, Mac Catalyst 254/254, Android API 35 all 8 sheet tests pass, Windows 48/48 run (3 existing skips).
↑ Runtime validated and recorded on iPhone (portrait and landscape), iPad landscape, a physical Pixel 10 with Material 3 (portrait and landscape) and a Windows DevBox; also on the Android emulator and Mac Catalyst.
↑ The Mac Catalyst run found a stray grabber on the presenting window, fixed in db01fee.
↑ GPT-6.2, Gemini 4 and Sonnet 5.5 signed off after two review rounds; every regression test added for review findings was verified to fail without its fix.
↓ Real touch drags on the physical Pixel were cut short by a flaky USB connection; drags were validated on the emulator.
↑
BottomSheet.IsSupported(12e80e5): device-test helpers assert it matches the observed presentation; Mac Catalyst 254/254, Android API 35 129/131 (2 pre-existing failures), Windows 48 passed / 3 existing skips; Controls.Core builds for every TFM.↓ iOS device tests not rerun after the IsSupported change (iOS build passes; same helper change as Catalyst).
↓ CI not run yet.
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!
Target Branch
mainnet11, for reviewDescription of Change
A first-party bottom sheet that uses what the OS provides natively:
UISheetPresentationControlleron iOS/Mac Catalyst and Material'sBottomSheetDialogFragmenton Android.A sheet is a modal presentation of a page, so it reuses modal navigation, lifecycle, back handling and Shell routing:
Common API (attached properties on
BottomSheet)IsEnabled(false) – present the modal as a sheet.Detents– 1 to 3 ofMedium,Large,FitContent,Fraction(x)/"40%",Height(h)/"300". Three is Android's limit.SelectedDetent(two-way) – follows the user's drags;nullmeans the smallest stop.HasDragHandle(true),IsDismissible(true; only affects interactive dismissal, neverPopModalAsync),CornerRadius(-1 = platform default).BottomSheet.IsSupported(static) –trueon Android, iOS and Mac Catalyst,falseelsewhere, so apps can pick another presentation (for example a flyout) where there is no native sheet.BottomSheetPrefersEdgeAttachedInCompactHeight,BottomSheetPrefersScrollingExpandsWhenScrolledToEdge.Platforms
ModalInPresentation; user detent changes written back via the sheet delegate; FitContent measures the content; iOS 26+ keeps the Liquid Glass material when the page has no background. Mac Catalyst shows the page in a centered macOS window sheet: the OS ignores detents, the drag handle is not shown, and the sheet closes through the page (for example a Close button), not by clicking outside or pressing Escape.BottomSheetDialogFragment; detents map to peek height / half-expanded ratio / expanded offset. MAUI's back routing runs first (an innerNavigationPagepops before the sheet dismisses), predictive back is forwarded, outside taps honorIsDismissible, the content handles system insets and the keyboard, and the Material 3 drag handle also shows in Material 2 apps.BottomSheet.IsSupportedisfalseand the page shows as a normal modal; the sheet appearance and behavior properties are ignored. With Shell,IsEnabledstill presents the page modally, the same as on the other platforms. A WinUI surface (for example aContentDialog-style or anchored flyout presentation) could be explored separately.Modal stack sync: when the user dismisses a sheet natively (swipe, outside tap, back),
ModalNavigationManager.OnPlatformModalDismissedAsyncpops it like any other modal, including through Shell. IfModalPoppingcancels, the sheet is presented again with its inner navigation intact. If aShell.Navigatingdeferral is still pending, the dismissal is checked again when the deferral completes, so a modal pushed in the meantime is never popped by mistake. iOS's existing PageSheet swipe-to-dismiss uses the same path now.Related fix: Shell used to retry forever when a
ModalPoppinghandler canceled a route's modal pop (with a page pushed underneath). It now stops that navigation.Design and review: the API was debated over two rounds with GPT-6.2, Gemini 4 and Claude Sonnet 5.5 (non-modal sheets and typed results were deferred). The code then went through two multi-model review rounds, and all three signed off after the findings were fixed. Community libraries consulted for inspiration: The49.Maui.BottomSheet, Plugin.Maui.BottomSheet, react-native-screens' form sheet.
Known limitations: non-modal (persistent) sheets and returning typed results aren't included. On Mac Catalyst the OS ignores detents and the drag handle.
Validation
dotnet build src/Controls/src/Core/Controls.Core.csproj -c Release -p:PublicApiType=Validatefor android, ios, maccatalyst, net and netstandard: passed with no errors.dotnet test src/Controls/tests/Core.UnitTests --filter "BottomSheet|Modal|Shell|Navigation": 934 passed. In the full run,TwoWayBindingToNullableDoublePropertyWithEmptyStringBecomesNullandStoppingFromPropertyChangingDuringATakeoverRaisesOnePairOfNotificationsfail on this machine for an unrelated reason: the local culture uses a decimal comma ("3,14").dotnet test src/Controls/tests/Xaml.UnitTests --filter BottomSheet: 3/3 passed (Runtime, XamlC, SourceGen).Run-DeviceTests.ps1 -Project Controls -Platform ios -TestFilter Category=Modal: 250/250 passed (iPhone 18 Pro iOS 27.0, iPhone 11 Pro iOS 26.5).Run-DeviceTests.ps1 -Project Controls -Platform android -TestFilter Category=Modal(API 35 emulator,EmbedAssembliesIntoApk=true): 129/131. All 8 bottom sheet tests pass. The 2 failures are the existingModalWindowInheritsActivitySystemBarForegroundAppearance, which this PR doesn't touch:Window.StatusBarColorhas no effect on API 35.Run-DeviceTests.ps1 -Project Controls -Platform maccatalyst -TestFilter Category=Modal: 254/254 passed.Run-DeviceTests.ps1 -Project Controls -Platform windows -TestFilter Category=Modal(Windows DevBox): 48 passed, 0 failed, 3 skipped (existing tests marked "Fails on Windows"). The sheet testsBottomSheetPushAndPopKeepsModalStackInSync(with and without Shell) andRapidBottomSheetPushAndPopLeavesNoSheetBehindpass. Controls.Core builds for Windows with 0 errors.BottomSheet.IsSupportedpublic: Mac Catalyst Modal 254/254, Android API 35 Modal 129/131 (same 2 pre-existing failures), Windows Modal 48 passed / 3 existing skips, Controls.Core BottomSheet + ShellModal unit tests 95/95. The device-test helpers assertIsSupportedistruewhere a native sheet was observed andfalseon Windows.PageHandler), then pops, pushes again and pops, ending with an empty modal stack and no errors.SelectedDetent, content updates, NavigationPage push/back inside the sheet, and Close with no layout loop. This run found the stray grabber, now fixed.UseMaterial3=true), portrait and landscape: every scripted scenario below runs with the M3 surface, shape and drag handle; Material caps the sheet width in landscape. Real touch drags were cut short because the phone's USB connection kept dropping, so drags were validated on the emulator only.BottomSheetPrefersEdgeAttachedInCompactHeightis set.Screenshots
Recordings
Each recording plays the same script: Medium/Large selection, three detents with a fraction, FitContent growing, drag handle and corner radius, a sheet over a sheet, a NavigationPage push and pop inside a sheet, a form with the keyboard, a CollectionView, and (iOS-specific) an edge-attached sheet.
iPhone 18 Pro, iOS 27, portrait
iphone-portrait.mp4
iPhone 18 Pro, iOS 27, landscape
iphone-landscape.mp4
iPad Pro 11-inch, iOS 27, landscape
ipad-landscape.mp4
Pixel 10, Android 16, Material 3, portrait
android-m3-portrait.mp4
Pixel 10, Android 16, Material 3, landscape
android-m3-landscape.mp4
Windows (DevBox): no native sheet, so each page shows as a regular modal. The demo pushes a sheet page, a NavigationPage sheet with a detail push and pop, and a sheet over a sheet, and finishes with an empty modal stack and no errors.
windows-sheet-demo.mp4
Issues Fixed
Fixes #