Skip to content

fix(toast): show toast above presented view controllers on iOS - #2644

Open
Albermonte wants to merge 1 commit into
ionic-team:mainfrom
Albermonte:fix/toast-topmost-view-controller
Open

Albermonte wants to merge 1 commit into
ionic-team:mainfrom
Albermonte:fix/toast-topmost-view-controller

Conversation

@Albermonte

@Albermonte Albermonte commented Nov 25, 2026 •

Copy link
Copy Markdown

On iOS, Toast.show() shows nothing and resolves right away while another view controller is presented over the webview, such as @capacitor/browser or an in-app browser plugin. ToastPlugin.show always adds the toast to bridge.viewController.view, which sits behind the presented view controller.

This PR walks presentedViewController from bridge.viewController on the main thread and shows the toast in the topmost one, matching how @capacitor/share picks its presenter since #2574. The walk stops before a view controller that is being dismissed or a UIAlertController, since an alert's view is only the alert box. With nothing presented, the toast stays in bridge.viewController.

Tested on an iPhone 17 simulator running iOS 27.0 using the repro from #2643, with this change applied to 8.0.1 as a pnpm patch on the with-fix branch.

Before: no toast while the Browser is open, Toast.show() resolves at 3.1 s. After: toast shown over the Browser, resolves at 7.4 s

Fixes #2643

@Albermonte
Albermonte marked this pull request as ready for review November 25, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toast: nothing shown on iOS while a view controller is presented over the webview

1 participant