Fix wrongful closing modal when using MediaPicker#31500
Merged
jfversluis merged 3 commits intonet10.0from Sep 9, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a critical issue where MediaPicker would incorrectly dismiss modal pages on iOS when the camera UI was canceled. The fix changes the dismissal logic to dismiss only the camera picker instead of the parent view controller.
- Corrects variable reference in MediaPicker dismissal logic from
vctopicker - Adds comprehensive UI tests to verify modal pages remain open after MediaPicker interactions
- Provides test coverage for both photo and video capture scenarios
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Essentials/src/MediaPicker/MediaPicker.ios.cs | Fixes dismissal logic to use correct view controller reference |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue31075.cs | Adds UI tests to verify modal behavior with MediaPicker |
| src/Controls/tests/TestCases.HostApp/Issues/Issue31075Modal.xaml.cs | Implements modal page with MediaPicker functionality for testing |
| src/Controls/tests/TestCases.HostApp/Issues/Issue31075Modal.xaml | Defines UI for modal test page with MediaPicker buttons |
| src/Controls/tests/TestCases.HostApp/Issues/Issue31075.xaml.cs | Implements main test page that opens the modal |
| src/Controls/tests/TestCases.HostApp/Issues/Issue31075.xaml | Defines UI for main test page with modal trigger |
jsuarezruiz
suggested changes
Sep 5, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
jsuarezruiz
approved these changes
Sep 9, 2025
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.
Copilot got the fix right in #31470 but had trouble bringing this to the .NET 10 branch.
Fixes #31075
Original description:
Fixes a critical issue where MediaPicker would incorrectly dismiss the entire modal page instead of just the camera UI when used from within a modal context on iOS.
Problem
When calling
MediaPicker.CapturePhotoAsync()orMediaPicker.CaptureVideoAsync()from within a modal page on iOS, canceling the camera UI would unexpectedly dismiss the entire modal page, not just the camera interface. This happened because the dismissal logic was callingDismissViewControllerAsyncon the wrong view controller.Solution
Changed the dismissal logic in
MediaPicker.ios.csfrom:to:
This ensures that only the camera picker is dismissed, not the parent modal page that presented it.
Testing
Added comprehensive UI tests (
Issue31075) that verify:Platform: iOS
Target Branch: net10.0