iOS: Fix autoCorrect doesn't revert to initial state#11055
Conversation
|
By analyzing the blame information on this pull request, we identified @javache and @janicduplessis to be potential reviewers. |
There was a problem hiding this comment.
nit: use correct type here UITextAutocorrectionType
Instead of repeating the logic here, extract this logic to an RCTConvert category.
There's an inconsistency in autoCorrect's default state: - If you don't specify a value for autoCorrect, it defaults to on. - If you specify true/false for autoCorrect and later specify null, autoCorrect turns off. The reason for this discrepancy is that autoCorrect is exposed to JS as a boolean but it is actually an enum with three states in native: - UITextAutocorrectionTypeDefault (the default value) - UITextAutocorrectionTypeYes - UITextAutocorrectionTypeNo This is fixed by explicitly mapping JS null to UITextAutocorrectionTypeDefault.
96d04c5 to
e8a8238
Compare
e8a8238 to
e8b53c2
Compare
|
@javache Thanks for the feedback. I pushed a change to address your feedback and rebased my branch on master. In my original change, I didn't implement an Whereas my actual implementation which converts JS booleans to native enum values is a little unusual. By the way, what's the reasoning for |
|
I'm not sure if the special casing for numbers is actually used. It allows you to just use the integers the enum maps to on the JS side to avoid passing over strings. |
|
@javache has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
This exposes iOS's spellCheckingType functionality to JavaScript. The native functionality is a three state enum. It gets exposed to JavaScript as a boolean. The initial value and JS null map to the third state. An alternative design for this API would have been to expose a three state enum to JavaScript: - "on" which maps to UITextSpellCheckingTypeYes - "off" which maps to UITextSpellCheckingTypeNo - "auto" (default) which maps to UITextSpellCheckingTypeDefault For consistency, I decided to use the same API design as spellCheck. We don't have many options for fixing spellCheck in react#11055 without introducing a breaking change.
Summary: This exposes iOS's spellCheckingType functionality to JavaScript. The native functionality is a three state enum. It gets exposed to JavaScript as a boolean. The initial value and JS null map to the third state. An alternative design for this API would have been to expose a three state enum to JavaScript: - "on" which maps to UITextSpellCheckingTypeYes - "off" which maps to UITextSpellCheckingTypeNo - "auto" (default) which maps to UITextSpellCheckingTypeDefault For consistency, I decided to use the same API design as spellCheck. We don't have many options for fixing spellCheck in #11055 without introducing a breaking change. **Test plan (required)** Verified that switching `spellCheck` between `true`, `false`, and `null` all work correctly in single line and multiline `TextInputs`. Closes #11056 Differential Revision: D4232802 Pulled By: javache fbshipit-source-id: 79e03307fa6a30a169f7e2fd0ec5ac826663e7c1
There's an inconsistency in autoCorrect's default state:
The reason for this discrepancy is that autoCorrect is exposed to JS as a boolean but it is actually an enum with three states in native:
This is fixed by explicitly mapping JS null to UITextAutocorrectionTypeDefault.
Test plan (required)
Verified that switching
autoCorrectbetweentrue,false, andnullall work correctly in single line and multilineTextInputs.Adam Comella
Microsoft Corp.