-
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
Allow overriding EditText construction in ReactTextInputShadowNode #27782
Allow overriding EditText construction in ReactTextInputShadowNode #27782
Conversation
The iOS CI failures don't appear to be related to the changes in this PR. |
I guess this seems fine, since it doesn't change any default behavior. Do you have examples of how you'd actually use this to override the default theme? |
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.
@JoshuaGross has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
The simplest example would be to just create an
This is actually a sufficient change to avoid the crash in #17530, and it also avoids applying padding based on the default Another example would be that you have a customized
|
@@ -249,4 +249,8 @@ public void setPadding(int spacingType, float padding) { | |||
super.setPadding(spacingType, padding); | |||
markUpdated(); | |||
} | |||
|
|||
protected EditText createDummyEditText() { |
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.
Let's call this something like createInternalEditText
or createEditTextForMeasure
since this is becoming a public API.
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.
Let's also add a javadoc here to document what this is for and how it can be used.
See comments; I'm mostly fine with this but if this is enabling someone to manually fix a crash, I w wonder if there's an additional, permanent solution to that crash. Requiring that everyone implement a custom TextInput component to avoid a crash doesn't seem great. |
bdfbbbe
to
71f5163
Compare
Agreed. Unfortunately, this can only be used to avoid the crash if you have a custom view that does not rely on the default If that crash fix were the only reason behind this change, I would be hesitant to suggest this change. I think it is the fact that this change allows the subclass to alter the behavior of the internal |
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.
@JoshuaGross has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This pull request was successfully merged by @mchowning in a5b5d1a. When will my fix make it into a release? | Upcoming Releases |
…27782) Summary: This PR makes it possible for subclasses of `ReactTextInputShadowNode` to control the construction of the "dummy" `EditText` instance that `ReactTextInputShadowNode` internally uses to determine the expected height of the view. This PR does not change the default behavior, it just opens up that default to being overriden. This is useful in the case of custom views that have different behavior from a "default" `EditText` instance (`new EditText(context)`). For example, it might have a different style applied. As a side benefit, this change also makes it easy to have subclasses not apply the default theme, which can allow the custom view to avoid a longstanding crash issue (#17530). ## Changelog [Android] [Added] - Allow overriding `EditText` construction in `ReactTextInputShadowNode` Pull Request resolved: #27782 Test Plan: All tests pass. Reviewed By: mdvacca Differential Revision: D19450593 Pulled By: JoshuaGross fbshipit-source-id: 8d2ce6117246fc3e2108623312b38583af5722b3
…acebook#27782) Summary: This PR makes it possible for subclasses of `ReactTextInputShadowNode` to control the construction of the "dummy" `EditText` instance that `ReactTextInputShadowNode` internally uses to determine the expected height of the view. This PR does not change the default behavior, it just opens up that default to being overriden. This is useful in the case of custom views that have different behavior from a "default" `EditText` instance (`new EditText(context)`). For example, it might have a different style applied. As a side benefit, this change also makes it easy to have subclasses not apply the default theme, which can allow the custom view to avoid a longstanding crash issue (facebook#17530). ## Changelog [Android] [Added] - Allow overriding `EditText` construction in `ReactTextInputShadowNode` Pull Request resolved: facebook#27782 Test Plan: All tests pass. Reviewed By: mdvacca Differential Revision: D19450593 Pulled By: JoshuaGross fbshipit-source-id: 8d2ce6117246fc3e2108623312b38583af5722b3
Summary
This PR makes it possible for subclasses of
ReactTextInputShadowNode
to control the construction of the "dummy"EditText
instance thatReactTextInputShadowNode
internally uses to determine the expected height of the view. This PR does not change the default behavior, it just opens up that default to being overriden.This is useful in the case of custom views that have different behavior from a "default"
EditText
instance (new EditText(context)
). For example, it might have a different style applied.As a side benefit, this change also makes it easy to have subclasses not apply the default theme, which can allow the custom view to avoid a longstanding crash issue (#17530).
Changelog
[Android] [Added] - Allow overriding
EditText
construction inReactTextInputShadowNode
Test Plan
All tests pass.