You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Android] Apply the button's managed handler config once per prop transaction (#4357)
## Description
Each prop setter on `RNGestureHandlerButtonViewManager` created or
reconfigured the button's managed `NativeViewGestureHandler` on its own.
That meant, per prop: a module lookup, a fresh config map, and a
registry lookup — and since React Native does not guarantee prop order,
`handlerTag` could be applied *after* the props meant to configure the
handler, so those updates were silently dropped.
Prop setters now only cache their value on the view and flag it dirty; a
single `updateManagedHandler` pass runs from `onAfterUpdateTransaction`
and creates, reconfigures or drops the handler from the cached state.
Other changes this required:
- The module is resolved by `moduleId` through a new
`RNGestureHandlerModule.getModule` (a `WeakReference` map cleaned up on
`invalidate`, and on a dangling read) rather than from the view's
context, so `moduleId` participates in the same batched update.
- A `handlerTag` that resets to its default (removed prop) now drops the
handler instead of leaving it attached.
- Cached props are cleared in `onDropViewInstance`: views are recycled
and props matching their default are not re-applied on the next mount,
so stale values would otherwise configure — or create — a handler for
the next button from the previous one's props.
- The config is now written in full every time, including `null`s, so a
removed `testID` or `hitSlop` actually clears on the handler.
## Test plan
- Buttons in `expo-example` still press, cancel on leave and respect
`hitSlop`/`testID`, including when those props are toggled or removed
after mount.
- Verified recycled buttons in a long list do not inherit the previous
item's handler config.
- Checked `enabled` changes still reach the handler.
Copy file name to clipboardExpand all lines: packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerButtonViewManager.kt
Copy file name to clipboardExpand all lines: packages/react-native-gesture-handler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt
0 commit comments