From 62741a1dc95d781b98b86f0904b90e1b64968cbd Mon Sep 17 00:00:00 2001 From: Jesse Katsumata Date: Sun, 29 Nov 2026 13:01:49 +0900 Subject: [PATCH] fix(android): don't override the child when MenuView is accessible or opens on long press Since #1190, MenuView makes every direct child clickable and focusable and replaces its click listener. When MenuView is itself accessible, TalkBack stops twice on the same element. In long press mode the replaced listener opens nothing, and the child's own onPress is lost. Leave the child alone in both cases, and make an accessible tap-to-open MenuView clickable so that it can still be opened from TalkBack. Fixes #1268 Co-Authored-By: Claude Opus 5.5 --- android/src/main/java/com/reactnativemenu/MenuView.kt | 7 +++++++ .../main/java/com/reactnativemenu/MenuViewManagerBase.kt | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/android/src/main/java/com/reactnativemenu/MenuView.kt b/android/src/main/java/com/reactnativemenu/MenuView.kt index cdbe544f..66f2bf81 100644 --- a/android/src/main/java/com/reactnativemenu/MenuView.kt +++ b/android/src/main/java/com/reactnativemenu/MenuView.kt @@ -53,6 +53,9 @@ class MenuView(private val mContext: ReactContext) : ReactViewGroup(mContext) { override fun addView(child: View?, index: Int, params: ViewGroup.LayoutParams?) { super.addView(child, index, params) + if (isFocusable || mIsOnLongPress) { + return + } // Make child views trigger menu when clicked via TalkBack child?.let { it.isClickable = true @@ -63,6 +66,10 @@ class MenuView(private val mContext: ReactContext) : ReactViewGroup(mContext) { } } + fun updateClickable() { + isClickable = isFocusable && !mIsOnLongPress + } + override fun onInterceptTouchEvent(ev: MotionEvent): Boolean { return true } diff --git a/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt b/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt index 9f02afa0..cdb57175 100644 --- a/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt +++ b/android/src/main/java/com/reactnativemenu/MenuViewManagerBase.kt @@ -35,6 +35,11 @@ abstract class MenuViewManagerBase : ReactClippingViewManager() { view.setIsOpenOnLongPress(isOnLongPress) } + override fun onAfterUpdateTransaction(view: MenuView) { + super.onAfterUpdateTransaction(view) + view.updateClickable() + } + override fun getExportedCustomDirectEventTypeConstants(): MutableMap { return MapBuilder.of( "onPressAction",