Repository navigation
fix(action-sheet,camera): show the Cancel action of action sheets on iPhone - #2631
Open
arblitroshani wants to merge 1 commit into
Open
arblitroshani wants to merge 1 commit into
arblitroshani wants to merge 1 commit into
Conversation
…iPhone With Liquid Glass (iOS 26+), UIKit presents an action sheet anchored by setCenteredPopover as a popover on iPhone too, and popovers hide the .cancel action. Skip the anchor on iPhone when the sheet has a Cancel action. Without one, keep the popover: tapping outside it is what cancels the sheet on iOS 26+. Fixes ionic-team#2630
arblitroshani
marked this pull request as ready for review
November 5, 2026 00:11
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.
Description
On iPhone, don't call
setCenteredPopoverfor action sheets that have a Cancel action:@capacitor/action-sheetshowActions(): when an option hasstyle: ActionSheetButtonStyle.Cancel.@capacitor/camerashowPrompt()(CameraSource.Prompt): always, since it always adds a Cancel action.Other idioms (iPad) keep the centred popover. On iPhone, an action sheet without a Cancel option keeps the popover too. On iOS 26+,
cancelablerelies on the popover's tap-outside dismissal (#2285), and an unanchored action sheet without a Cancel action can't be dismissed by tapping outside.Change Type
Rationale / Problems Fixed
Fixes #2630.
With Liquid Glass (iOS 26+), UIKit presents an anchored
.actionSheetas a popover on iPhone too, and popovers hide the.cancelaction.setCenteredPopoveranchors on every idiom. Before iOS 26, iPhone ignored the anchor.Tests or Reproductions
Minimal Capacitor 8.6 app with
@capacitor/action-sheetand@capacitor/camerainstalled from this branch, built with Xcode 27.0, on an iPhone 18 Pro simulator with iOS 27.0:showActions()with a Cancel option: before, a popover without Cancel. After, the system action sheet with Cancel. Tapping Cancel or outside resolves with the Cancel option's index.showActions()without a Cancel option,cancelable: true: a popover before and after. Tapping outside resolves with{ canceled: true, index: -1 }.getPhoto({ source: CameraSource.Prompt }): before, a popover without Cancel. After, the action sheet with Cancel, which rejects withUser cancelled photos app. "From Photos" still continues to the photo library.npm run lintandnpm run verify:iosinaction-sheetandcamera. Incamera,prettier --checkfails onCameraPlugin.java, which this PR doesn't touch.Not tested: iPad, iOS 18 and earlier, apps built with Xcode 26.
Screenshots / Media
iPhone 18 Pro simulator, iOS 27.0: 1. action-sheet before, 2. action-sheet after, 3. camera prompt before, 4. camera prompt after.
Platforms Affected
Notes / Comments
The same check could live in core
setCenteredPopoverinstead, by looking for a.cancelaction inUIAlertController.actions. That would also cover third-party plugins. Happy to move it there if you prefer.