Fix wrongful closing modal when using MediaPicker #31500
Merged
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