Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ public class ReactModalHostManager :
@ReactProp(name = "identifier")
public override fun setIdentifier(view: ReactModalHostView, value: Int): Unit = Unit

@ReactProp(name = "testID")
public override fun setTestId(view: ReactModalHostView, value: String?) {
super.setTestId(view, value)
view.setDialogRootViewGroupTestId(value)
}

protected override fun addEventEmitters(
reactContext: ThemedReactContext,
view: ReactModalHostView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import android.view.Window
import android.view.WindowInsetsController
import android.view.WindowManager
import android.view.accessibility.AccessibilityEvent
import android.view.accessibility.AccessibilityNodeInfo
import android.widget.FrameLayout
import androidx.annotation.UiThread
import com.facebook.common.logging.FLog
Expand Down Expand Up @@ -386,6 +387,15 @@ public class ReactModalHostView(context: ThemedReactContext) :
}
}

/**
* Sets the testID on the DialogRootViewGroup. Since the accessibility events
* are not triggered on the on the ReactModalHostView, the testID is forwarded
* to the DialogRootViewGroup to set the resource-id.
*/
public fun setDialogRootViewGroupTestId(testId: String?) {
dialogRootViewGroup.setTag(R.id.react_test_id, testId)
}

// This listener is called when the user presses KeyEvent.KEYCODE_BACK
// An event is then passed to JS which can either close or not close the Modal by setting the
// visible property
Expand Down Expand Up @@ -427,6 +437,15 @@ public class ReactModalHostView(context: ThemedReactContext) :
}
}

override fun onInitializeAccessibilityNodeInfo(info: AccessibilityNodeInfo) {
super.onInitializeAccessibilityNodeInfo(info)

val testId = getTag(R.id.react_test_id) as String?
if (testId != null) {
info.viewIdResourceName = testId
}
}

override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
viewWidth = w
Expand Down
Loading