-
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
Restore TouchableHighlight and TouchableOpacity behaviour on TV platforms #21478
Conversation
Incorrect link was blocking tvOS build
Restores the documented highlight and opacity behaviour on TV
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Excellent work @gtebbutt. Merging this pull request will unblock our project. |
Thank you @gtebbutt and everyone involved. I can't wait to try it. |
Thank you for the fix @gtebbutt This is blocking a project of mine 👍 |
Generated by 🚫 dangerJS |
@kelset @dlowder-salesforce No doubt you guys are super busy, but I wanted to check if there's any chance of getting this merged? Looks like this is blocking several TV projects (my own included), so it would be very much appreciated if this could get in for the next release. |
Any update on this ? Really need that to continue work |
I'm worried that this is a breaking change that removes functionality that is part of |
@cpojer Thank you for following up - I very much appreciate the feedback. Apologies in advance if I've misunderstood at all; this is my first jump into the RN source! I'd look at it slightly differently, in that the actual breaking change was #18470 - it changed the interface in a way that removed functionality on all non-touch platforms, both for the default components and for third-parties that consume It does so silently, making the issue difficult to trace, and it does so in a way that's not consistent between touch and non-touch platforms. It's also comparatively difficult to fix, as the end-user needs to dig inside the library to find and duplicate the touch functionality in What I'd say this PR does is takes the existing silent breaking change, and makes it visible. Implementers of I'd also worry that a flag would create an inconsistency between touch and non-touch UIs that would be somewhat frustrating for cross-platform developers. All that said, I'm happy to make changes if you do still think they would be necessary! |
@gtebbutt yes, you are right that the other change was a an unintended breaking change but that has nothing to do with this PR. The point I'm trying to make is that you are removing functionality from What I am proposing instead is to keep the focus and blur functionality in Touchable and adding a prop to disable the default focus and blur functionality. This prop would be passed by all the components you are modifying in this PR that are wrapping Touchable. That way you'd fix the bug in question without breaking Touchable's focus and blur behavior. The downside is that maintainers of external components will have to make the same adjustment if they are supporting non-touch platforms, but that should be ok. |
Understood. I was under the impression that a missing abstract method implementation on a component using a mixin would throw an error, but it looks like I was mistaken on that one. Since I'm definitely the newbie on this codebase though, so happy to do some digging and figure it out assuming you're confident that it's the better option, though. |
Oh wow, I have to admit I thought it was a higher order component but now I realize Touchable is a module from another era. I’ll give this another look tomorrow as well and will reply then unless you figure out a safe solution until then :) |
All good, thanks for taking the time! I'll do a little more digging this afternoon, but unless there's a flash of inspiration I'll wait for your follow up. |
Since mixins don't allow overwriting of methods, the only safe way I can think of is using a pattern similar to this: https://codesandbox.io/s/qzmx555mz6 Basically the idea is not to change Touchable at all, but instead also export a second mixin on Touchable that does not come with |
Allows implementers to optionally override behaviour without breaking existing use cases
Explains use case of Touchable.Mixin.withoutDefaultFocusAndBlur
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.
Code analysis results:
eslint
found some issues.
Good thinking - I've updated the PR to follow that pattern. |
Looks like the change is causing some flow errors - looking into it. |
OK, should be good to go now - AppVeyor issue looks unrelated. |
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.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Thank you!! This solution looks reasonable, I'm gonna land it. :) |
…orms (#21478) Summary: Since #18470, the default focus behaviour of `TouchableHighlight` and `TouchableOpacity` has been missing on tvOS. This uses the new `touchableHandleFocus` and `touchableHandleBlur` functions to restore the behaviour. Fixes #21295. Pull Request resolved: facebook/react-native#21478 Differential Revision: D13372959 Pulled By: cpojer fbshipit-source-id: a5fa9d45214ac48a14a6573ccf014bba1ee0a103
Since #18470, the default focus behaviour of
TouchableHighlight
andTouchableOpacity
has been missing on tvOS. This uses the newtouchableHandleFocus
andtouchableHandleBlur
functions to restore the behaviour. Fixes #21295.Test Plan:
Minimal example below works with expected colour/opacity changes on tvOS on React Native 0.55, but not on 0.57. This PR restores the documented behaviour as in 0.55.
Release Notes:
[GENERAL] [BUGFIX] [Touchable] - Restore focus behaviour for TouchableHighlight and TouchableOpacity on tvOS