Commit 19ef5d3
fix(share): present share sheet from the topmost view controller on iOS
On iOS, share() rejected with "Can't share while sharing is in progress"
whenever any view controller was presented over the bridge view controller,
not only when a share sheet was already open. Any app that presents a native
modal over the webview - an in-app browser, a camera or document picker, a
secondary WKWebView, a native auth session - could not share while that modal
was on screen, and the error reported a share state that did not exist.
Removing the guard alone is not enough: bridge.viewController cannot present
while it already has a presentedViewController, so UIKit logs "Attempt to
present ... which is already presenting ..." and no sheet appears.
Walk the presentation chain and reject only when a UIActivityViewController is
found in it, then present from the topmost view controller. Anchor the iPad
popover to that controller's own view, since setCenteredPopover anchors to
bridge.viewController.view, which is not in the presenter's hierarchy when
presenting from a different view controller.
Behaviour is unchanged when nothing is presented. This aligns iOS with the
Android implementation, which tracks an isPresenting flag and already rejects
only during an actual share.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 0bfde98 commit 19ef5d3
1 file changed
Lines changed: 21 additions & 5 deletions
File tree
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
70 | 87 | | |
71 | | - | |
72 | | - | |
| 88 | + | |
73 | 89 | | |
74 | 90 | | |
75 | 91 | | |
0 commit comments