Skip to content

Conversation

@ShaMan123
Copy link
Contributor

@ShaMan123 ShaMan123 commented Apr 15, 2020

Context

transformIntoHandlerTags creates an array of valid refs based on the value of the property _handlerTag of each ref passed to waitFor or simultaneousHandlers prop. The filtered array is then sent to native for configuration.

NativeViewGestureHandler

In the case of NativeViewGestureHandler the _handlerTag is set on the NativeViewGestureHandler ref properly.
HOWEVER, this value isn't passed to the ref of it's child. The child's ref is the one being passed back as the ref handler of the component. This makes sense.
However, in order to configure interactions on a different handler one would need to pass the NativeViewGestureHandler ref as part of waitFor or simultaneousHandlers prop.
This is IMPOSSIBLE because the NativeViewGestureHandler ref isn't exposed.
The child's ref is passed instead and is filtered out by transformIntoHandlerTags due to the lack of _handlerTag property, making it completely useless.

The End

This PR fixes the mentioned problem by setting the _handlerTag property on the NativeViewGestureHandler child's ref so when it is passed to waitFor or simultaneousHandlers it is treated as if it were a genuine gesture handler.

Expose `NativeViewGestureHandler ._handlerTag`  on `ref` to enable interaction configuration.
@jgonet jgonet self-assigned this Aug 23, 2020
@ShaMan123 ShaMan123 mentioned this pull request Aug 29, 2020
@ShaMan123
Copy link
Contributor Author

@jakub-gonet any plans on merging this?

@ShaMan123
Copy link
Contributor Author

ShaMan123 commented Oct 10, 2020

#963
I found a MAJOR bug that was preventing interaction management with native view handlers.
cf8e911 fixes the ability to configure interactions with NativeViewGestureHandler based on createHandler#transformIntoHandlerTags.

Originally posted by @ShaMan123 in #963 (comment)

@ShaMan123
Copy link
Contributor Author

updated description

Copy link
Member

@jgonet jgonet left a comment

Choose a reason for hiding this comment

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

Looks good except for one unused import. I'll commit it and merge after CI passes.

@MoOx
Copy link

MoOx commented Jan 24, 2021

Would be nice to have this in a release :)

braincore pushed a commit to braincore/react-native-gesture-handler that referenced this pull request Mar 4, 2021
### Context
[`transformIntoHandlerTags`](https://github.com/software-mansion/react-native-gesture-handler/blob/master/createHandler.js#L91) creates an array of valid refs based on the value of the property `_handlerTag` of each ref passed to `waitFor` or `simultaneousHandlers` prop. The filtered array is then sent to native for configuration.
### `NativeViewGestureHandler` 
In the case of `NativeViewGestureHandler` the `_handlerTag` is set on the `NativeViewGestureHandler` ref properly.
**HOWEVER**, this value isn't passed to the ref of it's child. The child's ref is the one being passed back as the ref handler of the component. This makes sense.
**However**, in order to configure interactions on a different handler one would need to pass the `NativeViewGestureHandler` ref as part of `waitFor` or `simultaneousHandlers` prop. 
This is **IMPOSSIBLE** because the `NativeViewGestureHandler` ref isn't exposed.
The child's ref is passed instead and is filtered out by `transformIntoHandlerTags` due to the lack of `_handlerTag` property, making it completely useless.
### The End
This PR fixes the mentioned problem by setting the `_handlerTag` property on the `NativeViewGestureHandler` **child's ref** so when it is passed to `waitFor` or `simultaneousHandlers` it is treated as if it were a genuine gesture handler.

Co-authored-by: Jakub <[email protected]>
@ucheNkadiCode
Copy link

Can someone provide a code example of how to use this? I am still having trouble with

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.

4 participants