[General] Default GestureDetector moduleId to -1 (#4412)
## Description On Android with Fabric props 2.0, `getDiffProps` on CREATE compares against codegen defaults. `moduleId: Int32` defaults to `0`, which is also the first `RNGestureHandlerModule` id, so the prop is omitted. The native field stays at `-1`, attach is skipped, and `removeViewAt` looks up `registries[-1]` and crashes (`Tried to access a non-existent registry`). Reproduced with `moduleId=-1`, `nativeHandlers=0`, `registryKeys=[0]` — the registry exists; `setModuleId` never ran. Two changes: 1. **Root cause** — match the button spec: `moduleId?: WithDefault<Int32, -1>` on the detector and root view so `0` is sent on CREATE and `setModuleId` runs. 2. **Safety net** — `detachNativeGestureHandlers` no-ops when the registry is missing (`?: return`), same as `detachAllHandlers()`. `removeViewAt` must not throw even if `moduleId` is still `-1` or the module has already been invalidated. ## Test plan - [ ] Android, New Architecture, props 2.0 / pull model enabled - [ ] Mount a `GestureDetector` (e.g. `Gesture.Native()` wrapping a list), then unmount it (navigate away) - [ ] App does not crash; native gestures still attach - [ ] Confirm the detector receives `moduleId=0` (not left at `-1`) --------- Co-authored-by: Cursor <cursoragent@cursor.com>
J
Jakub Kosmydel committed
50ae6a168914887785a8ed6b9742c63b45067f1c
Parent: 8b661c9
Committed by GitHub <noreply@github.com>
on 8/13/2026, 9:14:08 AM