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

[iOS] Fix semi-transparent backgrounds on Text components #23872

Closed
wants to merge 13 commits into from

Conversation

ericlewis
Copy link
Contributor

@ericlewis ericlewis commented Mar 12, 2019

Summary

Fix #23849. When setting a semi-transparent background on text, it becomes obvious that we are drawing the background color twice. Since background color is handled by the view, we should not need to draw the glyph background color too.

Before After

Changelog

[iOS] [Fixed] - Semi-transparent backgrounds on text

Test Plan

Added a new section to iOS RNTester Text Examples, CI passes. Also confirmed the TextExample snapshot tests passed with this change before I added the new test & snapshot.

@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 Mar 12, 2019
@ericlewis
Copy link
Contributor Author

ericlewis commented Mar 12, 2019

the test failing seems unrelated. e2e test for DatePickerIOS.

@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 12, 2019
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.

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

Copy link
Contributor

@shergin shergin left a comment

Choose a reason for hiding this comment

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

❤️
The problem does exist, but that's not a proper place to fix it. We should not apply background color for outer VirtualText.
To be sure, create a test with nested background like this:

<Text style={{backgroundColor: '#00000020', padding: 10}}>
Text in a gray box!
<Text style={{backgroundColor: 'red'}}>another text in red box</Text>
</Text>

@ericlewis
Copy link
Contributor Author

I pushed changes to reflect (I think) what you said, but it breaks other places in the RNTester app.

If I understand you correctly, it should look like this:

image

But this has undesired effects when text doesn't have children:

image 2

So should the solution be to allow the background to be drawn so the after image works & so the nested backgrounds work?

@ericlewis ericlewis requested a review from shergin March 13, 2019 16:39
@ericlewis
Copy link
Contributor Author

@shergin fixing the snapshot now, changing the TextExample.ios.js dirtied it.

@ericlewis ericlewis changed the title [iOS] Don’t draw background for text glyphs [iOS] Fix semi-transparent backgrounds on Text components Mar 13, 2019
@ericlewis ericlewis added Component: Text Contributor A React Native contributor. and removed Contributor A React Native contributor. labels Mar 13, 2019
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.

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

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @ericlewis in bbf7156.

When will my fix make it into a release? | Upcoming Releases

@react-native-bot react-native-bot added Merged This PR has been merged. and removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Mar 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Component: Text Merged This PR has been merged. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding semi-transparent background color to Text component causing display issue on iOS
5 participants