Handle autoCapitalize for native <TextInput />#436
Conversation
necolas
left a comment
There was a problem hiding this comment.
Thanks for working on this. Generally looks good, just a few tweaks
| let _autoCapitalize; | ||
| switch (autoCapitalize) { | ||
| case 'on': | ||
| case true: |
There was a problem hiding this comment.
I think we can get rid of the boolean. I don't see it as part of the standard
| autoCapitalize?: ?( | ||
| | true | ||
| | 'off' | ||
| | 'none' | ||
| | 'on' |
There was a problem hiding this comment.
RN doesn't support off and on so they shouldn't be in this type
| | 'off' | ||
| | 'none' | ||
| | 'on' |
There was a problem hiding this comment.
Potentially we could remove off and on as they were part of the pre-standard, iOS version of autoCapitalize and were retained for backwards compatibility. Not necessary for now, just putting it out there.
There was a problem hiding this comment.
Makes sense to me. 👍
As per the spec:
onis covered/duplicated bysentencesoffis covered/duplicated bynone
Just to say it: removing these 2 values would cause type errors in consuming projects that use them, so it might be useful to add a note in the next release.
| // web only | ||
| 'on', | ||
| 'off', | ||
| // web & native | ||
| 'none', // used instead of 'off' | ||
| 'sentences', // used instead of 'on' | ||
| 'words', | ||
| 'characters' |
There was a problem hiding this comment.
This test is just for native, and if we're supporting all 6 values it's confusing (and inaccurate) to have comments like "web only".
|
On an aside - I had a look at the failing CI jobs before force-pushing: Wondering if it might be related to this: peter-evans/create-or-update-comment#395 |
|
Thanks |
|
Sorry to comment on a closed PR - I'm not even sure you'll be notified. I'd love to use this change downstream in a project :) |
|
I'll cut a release today. Thanks for the reminder |
|
Sorry for the delay. Just published 0.0.55 |
|
Thank you! |
|
👋 Once again, sorry for commenting on a closed PR. I didn't want to create a fresh issue or discussion just for this. When trying to upgrade RSD to 0.0.55 (we use yarn v4, so › yarn up 'react-strict-dom'
➤ YN0000: · Yarn 4.9.2
➤ YN0000: ┌ Resolution step
➤ YN0082: │ postcss-react-strict-dom@npm:0.0.55: No candidates found
➤ YN0000: └ Completed
➤ YN0000: · Failed with errors in 0s 120msI've checked main, and the However, I don't see a 0.0.55 Release, and the latest version on npmjs.com is 0.0.54 Could I kindly ask you to have a look? |
|
Should be published now |
The
autoCapitalizeprop is not being forwarded through to the native input component. Which means that the following has no effect on the mobile device software-keyboard when the input is focused:This change maps the
autoCapitalizeprop's various values to the underlying native<TextInput />element, and allows the software-keyboard to react to the prop.There is some complexity with mapping the prop's values since the types declare a list larger than what is supported in react-native.
The declared type's values are:
The list of supported values in react-native is:
Further, there was also an existing test which assumed that the
autoCapitalizeprop could be set to booleantrue, as follows:The way this PR maps these values has been based on the MDN docs:
true👋 Quick disclaimer