-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix native gesture reattach #3672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see that android got a bit "out of sync" with iOS, can we make it so that one is analogous to another?
@@ -152,7 +154,8 @@ - (void)updateProps:(const Props::Shared &)propsBase oldProps:(const Props::Shar | |||
|
|||
if (handlerChange.second == RNGestureHandlerMutationAttach) { | |||
if ([self shouldAttachGestureToSubview:handlerTag]) { | |||
[_nativeHandlersToAttach addObject:handlerTag]; | |||
[_attachedNativeHandlers addObject:handlerTag]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we move this into tryAttachHandlerToChildView
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional, as tryAttachHandlerToChildView
is also used in didAddSubview
. attachedNativeHandlers
is intentionally not cleaned on reattach, thus there is no need to call addObject
again.
for (const id handlerTag : _attachedNativeHandlers) { | ||
[self tryAttachHandlerToChildView:handlerTag]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this loop moved outside of tryAttachHandlerToChildView
?
Also we could find better name for this method, like tryAttachNativeHandlersToChildView
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -102,24 +103,20 @@ class RNGestureHandlerDetectorView(context: Context) : ReactViewGroup(context) { | |||
val registry = RNGestureHandlerModule.registries[moduleId] | |||
?: throw Exception("Tried to access a non-existent registry") | |||
|
|||
for (tag in nativeHandlersToAttach) { | |||
for (tag in attachedNativeHandlers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a cosmetic note, but I don't like that we iterate through attachedNativeHandlers
and call attachHandlerToView
- it looks like we try to attach it again, which is not the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the variable name to nativeHandlers
Description
In
NativeDetector
native gesture failed to reattach when child changed.Test plan
Add a logging message in attach/detach in
android/.../react/RNGestureHandlerRegistry.kt
andapple/RNGestureHandlerRegistry.m
`