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

Map textContentType strings to Objective-C constants #22579

Conversation

levibuzolic
Copy link
Contributor

@levibuzolic levibuzolic commented Dec 10, 2018

Fixes #22578

Currently the only textContentType values that work are: username, password, location, name and nickname. This is due to the strings provided by React Native not matching up with the underlying string constants used in iOS (with the exception of the aforementioned types). Issue #22578 has more detail examples/explanation.

Test Plan:

Added a Text Content Type example to the RNTester app which shows two examples which weren't previously working.

Note: In my testing, most (if not all) textContentType values don't work on the simulator, instead they need to be tested on a real device.

Before After
img_1584 img_1583

Changelog:

[iOS] [Fixed] - Fixes textContentTypes not working by mapping textContentType strings to Objective-C constants - Fixes #22578

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Tests This PR adds or edits a test case. labels Dec 10, 2018
@levibuzolic levibuzolic force-pushed the map-textcontenttype-to-constants branch from 2edf7bc to 792c06b Compare December 10, 2018 05:12
@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 Dec 10, 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.

@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

@levibuzolic merged commit 077386a into facebook:master.

@facebook facebook locked as resolved and limited conversation to collaborators Dec 10, 2018
@react-native-bot react-native-bot added the Merged This PR has been merged. label Dec 10, 2018
@levibuzolic levibuzolic deleted the map-textcontenttype-to-constants branch December 10, 2018 23:46
@shergin
Copy link
Contributor

shergin commented Dec 11, 2018

Ooops, this diff was reverted because of some internal breakage. I will try to understand the exact reason and fix later this week.

@elicwhite
Copy link
Member

This PR failed with this log:

Summary: 
js/react-native-github/Libraries/Text/TextInput/RCTBaseTextInputView.m:238:83: error: use of undeclared identifier 'UITextContentTypeNewPassword'; did you mean 'UITextContentTypePassword'?
[CONTEXT]                 NSDictionary<NSString *, NSString *> * extras = @{@"newPassword": UITextContentTypeNewPassword,
[CONTEXT]                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
js/react-native-github/Libraries/Text/TextInput/RCTBaseTextInputView.m:239:83: error: use of undeclared identifier 'UITextContentTypeOneTimeCode'; did you mean 'UITextContentTypePostalCode'?
[CONTEXT]                                                                   @"oneTimeCode": UITextContentTypeOneTimeCode};
[CONTEXT]                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
stderr: js/react-native-github/Libraries/Text/TextInput/RCTBaseTextInputView.m:238:83: error: use of undeclared identifier 'UITextContentTypeNewPassword'; did you mean 'UITextContentTypePassword'?
[CONTEXT]                 NSDictionary<NSString *, NSString *> * extras = @{@"newPassword": UITextContentTypeNewPassword,
[CONTEXT]                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
js/react-native-github/Libraries/Text/TextInput/RCTBaseTextInputView.m:239:83: error: use of undeclared identifier 'UITextContentTypeOneTimeCode'; did you mean 'UITextContentTypePostalCode'?
[CONTEXT]                                                                   @"oneTimeCode": UITextContentTypeOneTimeCode};
[CONTEXT]                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

@levibuzolic levibuzolic restored the map-textcontenttype-to-constants branch December 12, 2018 04:35
@janicduplessis
Copy link
Contributor

Probably needs some #ifdef around the constants that are not defined in older ios versions.

@hramos hramos removed Import Started This pull request has been imported. This does not imply the PR has been approved. labels Feb 6, 2019
@levibuzolic levibuzolic deleted the map-textcontenttype-to-constants branch February 14, 2019 00:24
rozele pushed a commit to microsoft/react-native-windows that referenced this pull request Jul 18, 2019
Summary:
Fixes #22578

Currently the only `textContentType` values that work are: `username`, `password`, `location`, `name` and `nickname`. This is due to the strings provided by React Native not matching up with the underlying string constants used in iOS (with the exception of the aforementioned types). Issue #22578 has more detail examples/explanation.
Pull Request resolved: facebook/react-native#22579

Differential Revision: D13402177

Pulled By: shergin

fbshipit-source-id: 55f4a2029cd3ea1fb4834e9f56d2df5a05b31b4e
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: Text Merged This PR has been merged. Tests This PR adds or edits a test case.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants