Skip to content

[General] Fix onBegin not being called when the native recognizer skips the BEGAN state#3932

Merged
j-piasecki merged 1 commit intonextfrom
@jpiasecki/call-onbegin-when-skipped-natively
Jan 27, 2026
Merged

[General] Fix onBegin not being called when the native recognizer skips the BEGAN state#3932
j-piasecki merged 1 commit intonextfrom
@jpiasecki/call-onbegin-when-skipped-natively

Conversation

@j-piasecki
Copy link
Copy Markdown
Member

Description

The current state machine implementation allows for onBegin callback to be skipped if the native recognizer goes from UNDETERMINED directly to ACTIVE state (which is a valid transition in some cases).

This PR updates the logic to "backfill" the onBegin callback when receiving the UNDETERMINED -> ACTIVE transition, before calling onActivate.

Note: this PR only changes the behavior for the V3 API. I'm not sure whether it should be backported to V2 as it would likely be a breaking change.

Test plan

This scenario:

// NativeViewGestureHandler sends different events based on platform
state === (Platform.OS !== 'android' ? State.ACTIVE : State.BEGAN) &&

Copy link
Copy Markdown
Collaborator

@m-bert m-bert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR only changes the behavior for the V3 API. I'm not sure whether it should be backported to V2 as it would likely be a breaking change.

Did we have such issues before? While it seems important, I don't think we have to backport it atm.


Also, I've just noticed that this whole machine is one if ... else ... and nothing more below. We could "refactor" it at least to use early returns, maybe it would be a bit easier to read. But of course it's not the scope of this PR, so I can do it later.

@j-piasecki j-piasecki merged commit e1185cd into next Jan 27, 2026
2 checks passed
@j-piasecki j-piasecki deleted the @jpiasecki/call-onbegin-when-skipped-natively branch January 27, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants