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

Android TextInput: Support allowFontScaling on placeholder #22992

Closed

Conversation

rigdern
Copy link
Contributor

@rigdern rigdern commented Jan 15, 2019

Currently, the TextInput's placeholder is always sized as though allowFontScaling is true.

Note that allowFontScaling works fine for the content of the TextInput. The reason is that we set the font size in two places: in the shadow node and in the Android view. The shadow node logic determines the size of the content and the Android view logic determines the size of the placeholder. The handler for the allowFontScaling prop is only present in the shadow node logic. Consequently, the Android view logic always uses the default value of true for the allowFontScaling prop.

The fix is to add logic for handling the allowFontScaling prop to the Android view.

It would be great if we could handle all text props in one spot instead of duplicating code between the shadow node and the Android view. That would eliminate this whole class of bugs. However, I don't have enough familiarity with the history of this code to know how hard that would be or if it's even possible.

Fixes #18827.

Test Plan:

Verified that Text, the content of a TextInput, and the placeholder of a TextInput are all rendered the same way for all values of allowFontScaling (undefined, true, false).

Changelog:

[Android] [Fixed] - TextInput: Support allowFontScaling on placeholder

Adam Comella
Microsoft Corp.

Currently, the `TextInput's` placeholder is always sized as though `allowFontScaling` is `true`.

Note that `allowFontScaling` works fine for the content of the `TextInput`. The reason is that we set the font size in two places: in the shadow node and in the Android view. The shadow node logic determines the size of the content and the Android view logic determines the size of the placeholder. The handler for the `allowFontScaling` prop is only present in the shadow node logic. Consequently, the Android view logic always uses the default value of `true` for the `allowFontScaling` prop.

The fix is to add logic for handling the `allowFontScaling` prop to the Android view.

It would be great if we could handle all text props in one spot instead of duplicating code between the shadow node and the Android view. That would eliminate this whole class of bugs. However, I don't have enough familiarity with the history of this code to know how hard that would be or if it's even possible.

Fixes facebook#18827.

Test Plan:
----------

Verified that `Text`, the content of a `TextInput`, and the placeholder of a `TextInput` are all rendered the same way for all values of `allowFontScaling` (`undefined`, `true`, `false`).

Changelog:
----------

[Android] [Fixed] - TextInput: Support `allowFontScaling` on placeholder

Adam Comella
Microsoft Corp.
@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 Jan 15, 2019
@react-native-bot react-native-bot added 🔶Components Component: TextInput Related to the TextInput component. Platform: Android Android applications. labels Jan 15, 2019
@janicduplessis
Copy link
Contributor

@facebook-github-bot shipit

@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 Jan 15, 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.

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

@cpojer
Copy link
Contributor

cpojer commented Jan 16, 2019

Will re-import, something went wrong yesterday.

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.

@cpojer has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@react-native-bot
Copy link
Collaborator

@rigdern merged commit e605709 into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Jan 16, 2019
@react-native-bot react-native-bot added the Merged This PR has been merged. label Jan 16, 2019
@rigdern rigdern deleted the rigdern/allowFontScaling-TextInput branch January 16, 2019 21:01
@hramos hramos removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 6, 2019
matt-oakes pushed a commit to matt-oakes/react-native that referenced this pull request Feb 7, 2019
…k#22992)

Summary:
Currently, the `TextInput's` placeholder is always sized as though `allowFontScaling` is `true`.

Note that `allowFontScaling` works fine for the content of the `TextInput`. The reason is that we set the font size in two places: in the shadow node and in the Android view. The shadow node logic determines the size of the content and the Android view logic determines the size of the placeholder. The handler for the `allowFontScaling` prop is only present in the shadow node logic. Consequently, the Android view logic always uses the default value of `true` for the `allowFontScaling` prop.

The fix is to add logic for handling the `allowFontScaling` prop to the Android view.

It would be great if we could handle all text props in one spot instead of duplicating code between the shadow node and the Android view. That would eliminate this whole class of bugs. However, I don't have enough familiarity with the history of this code to know how hard that would be or if it's even possible.

Fixes facebook#18827.
Pull Request resolved: facebook#22992

Differential Revision: D13671400

Pulled By: cpojer

fbshipit-source-id: 40bae3cfb0ca6298e91a81c05211538935f5a0e8
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Component: TextInput Related to the TextInput component. Merged This PR has been merged. p: Microsoft Partner: Microsoft Partner Platform: Android Android applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Android] allowFontScaling prop on TextInput does not disable placeholder font scaling
6 participants