Skip to content
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

Update opacity when disabled prop is changed #17106

Conversation

maxkomarychev
Copy link
Contributor

@maxkomarychev maxkomarychev commented Dec 7, 2017

fixes #17105

If you render

    <TouchableOpacity
        disabled={true}
        style={{opacity: 0.5}}
    >
        ...
    </TouchableOpacity>

and then

    <TouchableOpacity
        disabled={false}
        style={{opacity: 1}}
    >
        ...
    </TouchableOpacity>

The content of TouchableOpacity will still have opacity = 0.5 because real
opacity is controlled by animated property which should be properly updated
when disabled prop changes.

Motivation

Usually when a button or other UI component is built with TouchableOpacity you may want to change it's opacity if state of component is changed (enabled/disabled). Opacity provided in props is overridden with internally-managed animated value. Add extra check when component is updated to trigger opacity animation upon change of disabled flag.

Test Plan

You can use code from #17105.

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/react-native-website, and link to your PR here.)

Release Notes

[GENERAL][BUGFIX][TouchableOpacity] - trigger animation on opacity upon change in disabled prop.

@facebook-github-bot
Copy link
Contributor

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!

@pull-bot
Copy link

pull-bot commented Dec 7, 2017

@facebook-github-bot label Android

Generated by 🚫 dangerJS

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 7, 2017
@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@maxkomarychev
Copy link
Contributor Author

Hi @hramos, when do you think this PR can be reviewed? Thanks.

@facebook-github-bot
Copy link
Contributor

@maxkomarychev I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

fixes facebook#17105

If you render

```
    <TouchableOpacity
        disabled={true}
        style={{opacity: 0.5}}
    >
        ...
    </TouchableOpacity>
```

and then

```
    <TouchableOpacity
        disabled={false}
        style={{opacity: 1}}
    >
        ...
    </TouchableOpacity>
```

The content of `TouchableOpacity` will still have opacity = 0.5 because real
opacity is controlled by animated property which should be properly updated
when `disabled` prop changes.
@maxkomarychev maxkomarychev force-pushed the feature/toggle-opacity-when-disabled-changed branch from ff94f25 to 3b2469d Compare January 6, 2018 20:41
@maxkomarychev
Copy link
Contributor Author

@dlowder-salesforce @lwinkyawmyat @levsero, could you please review or suggest who can do that? thanks.

@maxkomarychev
Copy link
Contributor Author

@javache

@jctf
Copy link

jctf commented Jan 15, 2018

Anyone reviewing this??

@tobiastornros
Copy link

Anyone reviewing this?

@danilobuerger
Copy link
Contributor

This again, valid patch, nobody reviewing... :(

@douglowder
Copy link
Contributor

I can review it, but I can't merge it.... maybe you can add release notes? @shergin might be the right person for this....

@maxkomarychev
Copy link
Contributor Author

@dlowder-salesforce updated release notes, appreciate your feedback! thanks!

@hramos
Copy link
Contributor

hramos commented Jan 26, 2018

@danilobuerger there's over a hundred PRs that have been filed ahead of this one. Please be patient!

@danilobuerger
Copy link
Contributor

@hramos Instead of being patient, maybe RN just needs more maintainers. Waiting for months to get something reviewed has a chilling effect on contributors. (Disclaimer: I know, this is open source, everybody is doing this on their free time. My point is: RN needs more maintainers).

@hramos
Copy link
Contributor

hramos commented Jan 26, 2018

Please consider the chilling effect you could have on existing maintainers as well. Fortunately, we do provide a path to contributing back to the repo: How to Contribute.

@danilobuerger
Copy link
Contributor

@hramos

Please consider the chilling effect you could have on existing maintainers as well.

So I shouldn't speak up if I think something isn't right? How would things ever change if we all had to be quiet and tiptoe around each other?

Fortunately, we do provide a path to contributing back to the repo: How to Contribute.

I know how to contribute, but that's not the issue when having > 100 PRs. It's missing maintainers.

@facebook-github-bot
Copy link
Contributor

@maxkomarychev I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project.

@oferRounds
Copy link

+1

@douglowder
Copy link
Contributor

@maxkomarychev I'm going to review and test this PR.... I'm curious, does TouchableHighlight not have the same issue?

Copy link
Contributor

@douglowder douglowder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the fix, works well on both iOS and tvOS.

@douglowder
Copy link
Contributor

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Something went wrong executing that command, @hramos could you take a look?

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Mar 5, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dlowder-salesforce is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@maxkomarychev
Copy link
Contributor Author

Thanks a lot @dlowder-salesforce .
As for touchable highlight - I did not meet this kind of issue with that component, but I didn't work with it too much though.

@ssuchanowski
Copy link

has this been merged yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TouchableOpacity does not let you control opacity when disabled prop changes
10 participants