-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
[Bug]: MarkerView does not invoke onPress handler in children #2880
Comments
Lint failed 😭Please fix the errors in your code example - More info.:
|
Please post a complete example. I wasn't able to reproduce with this one: import React from 'react';
import { TouchableOpacity, Image } from 'react-native';
import { MarkerView, MapView, Camera } from '@rnmapbox/maps';
const BugReportExample = () => {
return (
<MapView style={{ width: '100%', height: '100%' }}>
<Camera centerCoordinate={[-12.393354, 48.130477]} />
<MarkerView
coordinate={[-12.393354, 48.130477]}
anchor={{ x: 0.5, y: 1 }}
>
<TouchableOpacity
onPress={() => console.log('pressed')}
style={{
backgroundColor: 'transparent',
width: 30,
height: 42,
}}
>
<Image source={require('../assets/example.png')} />
</TouchableOpacity>
</MarkerView>
</MapView>
);
};
export default BugReportExample; |
Must be some very obscure bug because I have found out that |
@Epick362 what do you mean doesn't work? You can try to download our repo and example app, and reproduce the issue there. You can also try to put this component as the main component of the app to see if you can repro the issue or not. We can only look into the issue if we know something about the conditions where it's possible to reproduce the issue. |
Hey guys! I found an error and a solution. Dear developers @KiwiKilian! Please add onPress for If anything, write me to LikedIn) |
I'm also having this issue on iOS, and also have not been able to make it work with just the simple example you have provided @mfazekas (within my own project).
One thing I was thinking could be related is that we also use Reanimated within our project, so possibly it's corrupting something mapbox related? Going to keep investigating. |
@MichaelDanielTom can you also repro in a new project?! is your root component? |
Ok great suggestion, putting that as the root component did work! After some more testing it would appear that the culprit is react-navigation's stack navigator. I'm on the latest versions of all libraries, and if that component is literally anywhere, in the tree, as a parent, behind or in front or invisible, stuff starts screwing up. Notably, the native-stack-navigator does not cause this problem at all. All permutations of using/not using react-native-screens/react-native-freeze don't seem to have an effect. Will figure out if there's a straightforward solution in the next few days that involves still using the vanilla stack navigator, and will update this if so, but for anyone reading in the meantime, not using the stack navigator and instead using the native stack navigator shoulddddd fix it if your project permits. |
@MichaelDanielTom thanks amazing, we're using |
Ok so I was able to reproduce the issue with those changes: 1.) add
2.) Apply these changes to our App.js - import { createNativeStackNavigator } from '@react-navigation/native-stack';
+ import { createStackNavigator } from '@react-navigation/stack';
- const Stack = createNativeStackNavigator();
+ const Stack = createStackNavigator(); 3.) Use the following example: import React from 'react';
import { TouchableOpacity, Image } from 'react-native';
import { MarkerView, MapView, Camera } from '@rnmapbox/maps';
const BugReportExample = () => {
return (
<MapView style={{ width: '100%', height: '100%' }}>
<Camera centerCoordinate={[-12.393354, 48.130477]} />
<MarkerView
coordinate={[-12.393354, 48.130477]}
anchor={{ x: 0.5, y: 1 }}
>
<TouchableOpacity
onPress={() => console.log('pressed')}
style={{
backgroundColor: 'transparent',
width: 30,
height: 42,
}}
>
<Image source={require('../assets/example.png')} />
</TouchableOpacity>
</MarkerView>
</MapView>
);
};
export default BugReportExample; |
Awesome @mfazekas ! In that case do you think we should re-open this issue? Separately, I transitioned our app to only use nativeStackNavigator, however the bug seems to occasionally crop up still. Usually the touchables work ok on the first load, and then after moving around for some amount of time, something happens (not entirely sure what right now, could be loading different MarkerViews, unrelated components with touchables doing something, etc.), and it reverts to the bugged behavior where |
Update: I've narrowed it down to |
@MichaelDanielTom I've reported a bug to Hopefully they can give us some guidance on what could be going wrong |
Hi 👋! I've looked into it and it looks like there was some unintended interaction between Gesture Handler's root view recognizer and the recognizers of Mapbox - when one of the gestures activates, Gesture Handler will cancel the JS responder so they don't conflict with each other. The problem was that this can be triggered by every recognizer, so when a native gesture recognizer from Mapbox would activate, GH would cancel the JS responders. I've made a PR to only cancel the JS responders when activating recognizer is from Gesture Handler. Could you verify that it's solving the problem for you? |
@j-piasecki Seems to have fixed the issue for me at least - thank you so much! |
@j-piasecki thanks much it's also working great for me. "react-native-gesture-handler": "software-mansion/react-native-gesture-handler#@jpiasecki/cancel-responder-only-on-gh" |
…flow (#313) * fix: use #17bbcde react-native-gesture-handler See: #305 rnmapbox/maps#2880 (comment) * fix: set increment-build-number true or empty string * fix: add additional secrets to build workflow: GOOGLE_OAUTH_IOS_CLIENT_ID, GOOGLE_OAUTH_IOS_URI_SCHEME, PUBLIC_MAPBOX_TOKEN
The |
Mapbox Implementation
Mapbox
Mapbox Version
10.13.1
Platform
iOS
@rnmapbox/maps
version10.0.6
Standalone component to reproduce
Observed behavior and steps to reproduce
Click on the marker which is located in atlantic ocean and it fades (TouchableOpacity) but it is not logged into console.
Expected behavior
Pressed should be logged into console.
Notes / preliminary analysis
No response
Additional links and references
No response
The text was updated successfully, but these errors were encountered: