Skip to content

feat(android): add dialog root fallback for React Native Modal support#4933

Open
yuki2006 wants to merge 1 commit intowix:masterfrom
yuki2006:feat/android-modal-inroot-support-no-ci
Open

feat(android): add dialog root fallback for React Native Modal support#4933
yuki2006 wants to merge 1 commit intowix:masterfrom
yuki2006:feat/android-modal-inroot-support-no-ci

Conversation

@yuki2006
Copy link
Copy Markdown

@yuki2006 yuki2006 commented Apr 20, 2026

Summary

Adds automatic inRoot(RootMatchers.isDialog()) fallback on Android to support interactions with elements rendered inside React Native <Modal>.

Fixes #4928

Problem

On Android, React Native's <Modal> component renders its content in a separate dialog window root. Espresso's default view matching only searches the main window root, causing NoMatchingViewException for any element inside a Modal — even though the element is visible on screen.

This makes it impossible to test flows involving Modal (e.g. pickers, confirmation dialogs, bottom sheets) without manual inRoot workarounds, which Detox does not currently expose.

Solution

When a view interaction fails with NoMatchingViewException, automatically retry with .inRoot(RootMatchers.isDialog()). This is applied to:

  • Assertions (DetoxAssertion.java): assertMatcher and waitForAssertMatcher
  • Actions (SingleViewActionPerformer.kt, MultipleViewsActionPerformer.kt): perform

The fallback only triggers on NoMatchingViewException, so there is no impact on views found in the default root.

Changes

File Change
DetoxAssertion.java Dialog root fallback in assertMatcher() and waitForAssertMatcher()
SingleViewActionPerformer.kt Dialog root fallback in performOn()
MultipleViewsActionPerformer.kt Dialog root fallback in performOn()

Test plan

  • Verified with a React Native app using <Modal visible={true}> containing tappable elements and assertions
  • Existing tests unaffected (fallback only activates on NoMatchingViewException)

@yuki2006 yuki2006 marked this pull request as ready for review April 20, 2026 09:37
@yuki2006 yuki2006 requested a review from noomorph as a code owner April 20, 2026 09:37
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.

[Android] Support interacting with elements inside React Native Modal (Espresso inRoot)

1 participant