-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Touchables translated into view are not pressable on android #28894
Comments
I've used workarounds to solve it in the different cases I've had this issue:
|
@AdamGerthel I am facing a similar issue and wanted to see if you could provide some more clarification. By putting an invisible view behind the touchable surface, do you mean you wrapped the touchable opacity in a view that had no styles? |
@skay97 My code is too obscure for it to make immediate sense and it would take me too much time to rewrite it as a re-usable sample. Basically I first render this view: |
This line does not take in consideration the react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java Lines 114 to 115 in 0060b5d
The number of child react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java Lines 119 to 122 in 0060b5d
this is the logic checking that click react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java Lines 124 to 134 in 0060b5d
I need to apply the transformation before calculation the number of childrens react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java Line 115 in 0060b5d
I'll try to prepare a pull request tomorrow Thanks a lot |
react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java Line 320 in 0348953
The transformation is not yet applied and getChildCount will return react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java Lines 115 to 119 in 0060b5d
I can detect that the child react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java Line 122 in 0060b5d
Matrix childMatrix = child.getMatrix();
Log.w("TESTING::TouchTargetHelper", "childMatrix.isIdentity(): " + childMatrix.isIdentity());
// Logs false for ViewGroup id 0x17 (23) - a transformation has been applied and not taked in consideration calling react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java Line 324 in 0348953
another option is triggering with a callback this process after transformation is applied, instead of duplicating the logic |
My opinion is that issue #28894 and #27333 created by @bdrobinson and @AdamGerthel should be closed. Both issues do not include acceptable reproducible examples. @AdamGerthel in #27333 should have just applied @bdrobinson you can just fix #28894 by specifying the correct width of the View you want to transform. The View is not clickable because you apply Unluckily same and probably a duplicate of #27333 (comment) const styles = StyleSheet.create({
outerContainer: {
},
innerContainer: {
flexDirection: 'row',
width:1800,
transform: [{translateX: -200}]
},
}); If you want the ViewGroup to be clickable with a transform, you need to make sure it has the correct width. I invested a lot of time in both issues to find this mistake, so I would be thankful if you could close both issues. Thanks |
Thanks for looking into it so closely @fabriziobertoglio1987! You clearly understand the problem space a lot better than I do so I'm happy to defer to your opinion to make sure that this issue doesn't cause unnecessary noise for maintainers. However, I would question whether this is indeed an "invalid example" since it works on iOS and fails on Android? |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
This is still an issue. Use |
One use case is:
|
I agree that this is still an issue, and I don't agree with what @fabriziobertoglio1987 is saying either. The fact that a view is interpreted as having Basically, my take on it is that the height of the View should be calculated by the native Android code rather than being calculated by hand in JS. Assigning a fixed height prevents dynamic content from being placed in the view. Doing that is what I consider to be a bad workaround for an obvious bug. If See #27333 (comment) as well. |
I tried all the ideas mentioned above and nothing worked. ...I found replacement touchables from import {
TouchableNativeFeedback,
TouchableHighlight,
TouchableOpacity,
TouchableWithoutFeedback,
} from 'react-native-gesture-handler'; |
I get the same issue, I want to make a dropdown,in IOS everything is OK, but android is not work, Who can help me... |
I'm experiencing the same issue. It's a real bummer, because I've created a custom horizontal swiper (carousel), and @fabriziobertoglio1987 you mentioned you'd prepare a pull request - did you find a native fix for this? EDIT: Just read the comment about providing valid |
@mrousavy thanks for the reply If I still remember well my research explained in #28894 (comment) made me conclude that ReactAndroid will restrict touch events to parent view area available, so for example if you transform the parent view or set height/width = 0, then you can not touch the TouchableWithoutFeedback This is included in the ReactNative Touchable docs as I explained in #27333 (comment) regarding Probably reading their sourcecode may help us understand how to remove this limitation, but I believe the change will be complex I may be wrong as I did not work for long time on this issue, once I will have more free time I will have a further look at the issue. Thanks a lot. |
Hi ! Has anyone found a solution while waiting for the problem to be resolved ? Thanks. |
Also, don't if anyone noticed it but the same happens with FlatLists |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
Still valid issue i think |
yes its works. |
There is an open issue on React Native side: facebook/react-native#28894 that cannot be fixed now. That is why it has been decided to remove animations that use translateX styles. https://mindlogger.atlassian.net/browse/M2-1500
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
I'm organizing my next tasks. Are you still interested in adopting a fix for this issue? Or have you already implemented a workaround? If you are interested, I will work on a solution. Thanks |
I think this issue is an important one, because it will be raised to anyone who has a bigger icon in the middle of the bottom tab bar |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
Description
When a touchable is rendered offscreen (or possibly just outside the bounds of its parent) but moved into view using
translateX
/translateY
, it cannot be pressed. This bug is only present on Android, and works fine on iOS.There's been a few issues related to this that have been closed due to inactivity, so I'm opening a new one. They are:
(@AdamGerthel and @lehresman I'd be interested to know if you got any further debugging these issues?)
React Native version:
0.61.2
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
Expected Results
When you press the left/right buttons, both should be expected to respond to your touches (you can run on iOS to verify this). However, on Android only the left one responds to touches, whereas the right doesn't.
Snack, code example, screenshot, or link to a repository:
https://snack.expo.io/@bdrobinson/android-offscreen-touchable-bug (copy+pasted from #26219)
The text was updated successfully, but these errors were encountered: