Skip to content

[iOS] Present ActionSheetIOS from its anchor on iOS 26 iPhones - #59882

Open
ArekChr wants to merge 2 commits into
react:mainfrom
ArekChr:fix/action-sheet-anchor-ios26
Open

ArekChr wants to merge 2 commits into
react:mainfrom
ArekChr:fix/action-sheet-anchor-ios26

Conversation

@ArekChr

@ArekChr ArekChr commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

On iOS 26 an action sheet without a source view opens in the middle of the screen, like an alert. ActionSheetIOS has an anchor option to open it from the tapped button or row, but on iPhone it's ignored.

That was done on purpose in #54179: on iOS 26 an anchored popover lets the tap that closes it go through to the view behind, so tapping outside the sheet also pressed something else. #56200 reports the same for the share sheet.

This PR uses anchor on iOS 26 iPhones and blocks that tap instead. While the sheet is open, a transparent view covers the window under it. Tapping it closes the sheet and returns the cancel index, like UIKit does, and nothing behind gets pressed. If the anchor view is already gone from the window, the sheet opens centered as before.

Apart from that fallback, nothing changes without anchor or before iOS 26. On iPad with iOS 26 the anchored sheet gets the same cover.

Motivation:

The centered sheet looks like an alert and feels out of place in a native app. Apple's apps (Mail, Files, Photos) and apps like ChatGPT open these menus from the button or row you tapped. With this, RN apps get the same by passing anchor, which they already do for iPad.

Changelog:

[IOS] [FIXED] - ActionSheetIOS: open the sheet from anchor on iOS 26 iPhones and stop the tap outside it from pressing the view behind

Test Plan:

RNTester > ActionSheetIOS on an iPhone 17 Pro simulator, iOS 26.2.

  1. "Show Action Sheet with anchor", tap HERE. Before: centered sheet. After: the sheet opens next to HERE.
  2. With the sheet open, tap HERE in "Share from Anchor". After: the sheet closes with "Clicked button: Cancel" and the share sheet doesn't open.
  3. "Show Action Sheet" without anchor: centered, as before.

We use the same change as a patch-package patch in production (RN 0.88.1): list rows open their action sheet from the row on iPhone and iPad, iOS 18 and 26, with no issues.

BeforeAfter
action-sheet-anchor-before.mp4
action-sheet-anchor-after.mp4

On iOS 26 an iPhone action sheet without a source view is shown centred like an alert, and the anchor option of ActionSheetIOS.showActionSheetWithOptions is ignored on iPhone since 82d2352 because an anchored popover lets the background receive touches.

Use the anchor on iOS 26 iPhones when one is passed, and cover the window with a transparent control while the anchored sheet is shown, so a tap outside dismisses the sheet (selecting the cancel button) instead of pressing the view under it. An anchor that is no longer in a window falls back to the unanchored presentation.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 9, 2026
@facebook-github-tools facebook-github-tools Bot added p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Nov 9, 2026
@meta-codesync

meta-codesync Bot commented Nov 19, 2026

Copy link
Copy Markdown

@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this in D133248161.

@Abbondanzo Abbondanzo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few suggestions and a retain cycle fix required

- Break the self -> handler -> self cycle with a weak reference.
- Remove an old shield before presenting, and add the shield in the same place for both sheets.
- Anchored share sheets get the shield too; an outside tap reports completed: false once.
- Keep the shield while the share sheet stays open after backing out of an activity.
- Add the shield to the presenting window, iPhone only; iPad keeps UIKit's popover behaviour.
- Hide the shield from accessibility.
@ArekChr
ArekChr requested a review from Abbondanzo November 20, 2026 16:56
@github-actions

Copy link
Copy Markdown

Visual regression

No visual differences at b1c821901a2d.

android: no capture

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants