Skip to content

Conversation

@jfversluis
Copy link
Member

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() or MediaPicker.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 calling DismissViewControllerAsync on the wrong view controller.

Solution

Changed the dismissal logic in MediaPicker.ios.cs from:

await vc.DismissViewControllerAsync(true);

to:

await picker.DismissViewControllerAsync(true);

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:

  • Modal pages remain open after MediaPicker interactions
  • Both photo and video picker scenarios are covered
  • Tests are disabled on Windows platform where MediaPicker behaves differently

Platform: iOS
Target Branch: net10.0

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 vc to picker
  • 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

@jfversluis jfversluis enabled auto-merge (squash) September 9, 2025 10:26
@jfversluis jfversluis merged commit 8541619 into net10.0 Sep 9, 2025
148 checks passed
@jfversluis jfversluis deleted the fix-31075-net10 branch September 9, 2025 10:46
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants