Repository navigation
Fix: Present iOS pickers from the topmost view controller - #15
Merged
simonhamp merged 2 commits intoOct 22, 2026
Merged
Conversation
Camera::getPhoto(), recordVideo() and pickImages() presented on the key window's rootViewController. While any modal is on screen (e.g. a <native:bottom-sheet>, rendered as a SwiftUI .sheet) that controller is already presenting, so UIKit silently drops the present() call: no picker, no event, no log. Add a shared CameraPresenter that walks the presentation chain to the topmost controller before presenting, which also covers nested sheets. If the topmost modal is mid-dismissal (sheet closed in the same tap), it waits for that transition to complete before presenting, since UIKit also drops presentations made during one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199rrDNxmZMTFV31gcj8bJj
NativePHP#17 landed on main with a smaller version of this fix, so the three picker call sites conflicted. This keeps CameraPresenter and drops NativePHP#17's topViewController helper, because CameraPresenter also waits for a sheet that is still closing before it presents. Everything else from main, including NativePHP#13, comes through unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #11
On iOS,
Camera::getPhoto(),Camera::recordVideo()andCamera::pickImages()presented on the key window'srootViewController. While any modal is on screen (e.g. a<native:bottom-sheet>, which renders as a SwiftUI.sheet) that controller is already presenting, so UIKit silently drops thepresent()call: no picker, no event, no log.Changes
CameraPresenterthat walkspresentedViewControllerup to the topmost controller before presenting. This also covers nested sheets.transitionCoordinator, since UIKit also drops presentations made during one. That makes the@dismissworkaround from the issue unnecessary.VideoCancelled.registerForActivityResultlaunchers), so there are no Android changes.Testing
Tested on a physical iPhone 15 with an EDGE screen (
nativephp/mobile4.x +nativephp/mobile-ui0.4) that opens the pickers from inside a<native:bottom-sheet>:Note for anyone reproducing this: give the sheet a stable
native:key. Without one, the sheet's positional node id shifts when state rendered before it in the tree changes (e.g. a log line added on tap), and SwiftUI tears the sheet down, taking the camera presented on top of it with it. That's EDGE node identity, not something this plugin can guard against.