-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
feat: Add readOnly prop to TextInput component #34444
feat: Add readOnly prop to TextInput component #34444
Conversation
76717f3
to
27c6cc6
Compare
27c6cc6
to
a07a65c
Compare
Base commit: e0a71fc |
@necolas do we have an opinion on what should happen when both props are specified (and conflict)?
I'm thinking less about cases of users passing both directly, and more about HOCs/wrapper components that hide the use of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! Let's wait for an answer re: handling conflicts between readOnly
and editable
; the current design may already be fine - I just want to make sure we discuss it.
Thanks for this PR! It looks good.
My inclination is to say that the new props should take precedence, but I don't know the details of how the HOC use case could make that problematic. |
@@ -1392,6 +1400,7 @@ const ExportedForwardRef: React.AbstractComponent< | |||
allowFontScaling={allowFontScaling} | |||
rejectResponderTermination={rejectResponderTermination} | |||
underlineColorAndroid={underlineColorAndroid} | |||
editable={!readOnly} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're going to have readOnly
take priority over editable
. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, I've just updated the logic to match this.
1284786
to
2017605
Compare
* See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly | ||
* for more details. | ||
*/ | ||
readOnly?: ?boolean, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we try to roughly follow alpha-sort for props, but if it's not being flagged by a linter it's not a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I've just updated it to be in the right order
05e968e
to
21aec01
Compare
Base commit: e0a71fc |
@necolas has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@@ -1381,6 +1388,8 @@ const ExportedForwardRef: React.AbstractComponent< | |||
allowFontScaling = true, | |||
rejectResponderTermination = true, | |||
underlineColorAndroid = 'transparent', | |||
readOnly, | |||
editable, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about adding a deprecation message on editable
if it's used cc @cipolleschi. We could do that in a follow-up PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I can open a follow-up PR and also update the docs on /~https://github.com/facebook/react-native-website/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lunaleaps here is the follow-up PR #34492 and the PR updating the docs facebook/react-native-website#3278
This pull request was successfully merged by @gabrieldonadel in de75a7a. When will my fix make it into a release? | Upcoming Releases |
Summary
This adds the
readOnly
prop to TextInput as requested on #34424 mapping the existingeditable
prop toreadOnly
so thatreadOnly={false}
maps toeditable={true}
andreadOnly={true}
representseditable={false}
. This PR also updates the TextInputExample on the RNTest in order to facilitate the manual QA of this.Changelog
[General] [Added] - Add readOnly prop to TextInput component
Test Plan
TextInput
component through theEditable and Read only
sectionScreen.Recording.2022-08-18.at.01.39.04.mov