-
-
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
Fix native gesture reattach #3672
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?
packages/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm
Outdated
Show resolved
Hide resolved
packages/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm
Outdated
Show resolved
Hide resolved
...ler/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerDetectorView.kt
Outdated
Show resolved
Hide resolved
if (!self.subviews[0]) | ||
return; |
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.
Correct me if I'm wrong, but this should never happen with NativeHandler
and if it does, I believe we would like to throw an error instead of silent fail.
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.
That was my attempt to synchronise android and iOS as on Android we had this, on Android there is a comment that explains it. I'll move it to the right place
It might happen that
attachHandlers
will be called before children are added into view hierarchy
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.
Ok, you are right it can really only happen in the attachHandlers
, thus it's better to have a check only there. Fixed in 4916ba5.
// It might happen that `attachHandlers` will be called before children are added into view hierarchy. In that case we cannot | ||
// attach `NativeViewGestureHandlers` here and we have to do it in `addView` method. |
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 don't really see the point of moving this comment and removing part of its information. It was written in this place so that when you see adding to set instead of attaching handler you know why it happens.
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 thought, that the set would have been used regardless as we need it for reattach, so it wasn't the place for this comment. But ok, I don't have a strong opinion thus I restored it and synced ios, c4f18a7d
packages/react-native-gesture-handler/apple/RNGestureHandlerDetector.mm
Outdated
Show resolved
Hide resolved
Co-authored-by: Michał Bert <[email protected]>
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.
Good job! 🚀
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
`