diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ImportantForInteractionHelper.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ImportantForInteractionHelper.kt index 016706fb3adf8b..c20972602fa985 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ImportantForInteractionHelper.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/view/ImportantForInteractionHelper.kt @@ -14,12 +14,6 @@ import com.facebook.react.uimanager.PointerEvents /** * Helper class for managing the important_for_interaction view tag. This tag determines how a view * participates in interaction handling. - * - * The important_for_interaction value is a bitfield that can contain combinations of: - * - [IMPORTANT_FOR_INTERACTION_YES]: The view is important for interaction - * - [IMPORTANT_FOR_INTERACTION_NO]: The view is not important for interaction - * - [IMPORTANT_FOR_INTERACTION_EXCLUDE_DESCENDANTS]: Descendants should be excluded from - * interaction */ internal object ImportantForInteractionHelper { /** The view is important for interaction. */ @@ -31,21 +25,15 @@ internal object ImportantForInteractionHelper { /** Descendants of this view should be excluded from interaction handling. */ const val IMPORTANT_FOR_INTERACTION_EXCLUDE_DESCENDANTS: Int = 0x4 + /** CSS pointer-events: auto heuristics. */ + const val IMPORTANT_FOR_INTERACTION_AUTO_CSSPOINTEREVENTSAUTO: Int = 0x8 + /** * Sets the important_for_interaction tag on a view based on the given [PointerEvents] value. * * Note: The pointer events value alone does not determine if a view is important for interaction. - * A view with pointerEvents=auto or pointerEvents=box-only is only important for interaction if - * it is also clickable. Therefore, for these cases we let the view's own state determine whether - * it's important for interaction rather than setting the tag. - * - * The mapping is as follows: - * - [PointerEvents.AUTO] -> Tag removed (i.e. the view's own state determines importance) - * - [PointerEvents.NONE] -> [IMPORTANT_FOR_INTERACTION_NO] | - * [IMPORTANT_FOR_INTERACTION_EXCLUDE_DESCENDANTS] - * - [PointerEvents.BOX_ONLY] -> [IMPORTANT_FOR_INTERACTION_EXCLUDE_DESCENDANTS] (i.e. the view's - * own state determines importance but its descendants are excluded) - * - [PointerEvents.BOX_NONE] -> [IMPORTANT_FOR_INTERACTION_NO] + * A view with pointerEvents=auto or pointerEvents=box-only can be important for interaction if + * none of its ancestors is blocking pointer events with pointerEvents=none or box-none. * * @param view The view to set the tag on * @param pointerEvents The pointer events value to convert and set @@ -54,10 +42,12 @@ internal object ImportantForInteractionHelper { fun setImportantForInteraction(view: View, pointerEvents: PointerEvents) { val value = when (pointerEvents) { - PointerEvents.AUTO -> null + PointerEvents.AUTO -> IMPORTANT_FOR_INTERACTION_AUTO_CSSPOINTEREVENTSAUTO PointerEvents.NONE -> IMPORTANT_FOR_INTERACTION_NO or IMPORTANT_FOR_INTERACTION_EXCLUDE_DESCENDANTS - PointerEvents.BOX_ONLY -> IMPORTANT_FOR_INTERACTION_EXCLUDE_DESCENDANTS + PointerEvents.BOX_ONLY -> + IMPORTANT_FOR_INTERACTION_AUTO_CSSPOINTEREVENTSAUTO or + IMPORTANT_FOR_INTERACTION_EXCLUDE_DESCENDANTS PointerEvents.BOX_NONE -> IMPORTANT_FOR_INTERACTION_NO } view.setTag(R.id.important_for_interaction, value)