[Android][Fix] Revert Picker item original color#25750
Conversation
There was a problem hiding this comment.
Since you are touching this file, can you return textView instead?
mdvacca
left a comment
There was a problem hiding this comment.
Hey @cabelitos, thanks for fixing this!
It looks good to me, if you have 5 min to make that change it would be great. Otherwise I will just land this as it is!
|
Thank you for your review @mdvacca. I'm doing the change right now! |
Since the Android's Picker implementation uses an ArrayAdapter, it means that the views that were created may be reused for other items in order to save memory. With this in mind, if one sets the Picker.Item prop color for only certain items there might be an state that some items that does not have the color set will end up appearing with the wrong color. This happens becase, this new item is reusing a view of an item that had the color prop set. In order to avoid this problem, once a new view is created the ReactPickerAdapter will save the original color and re-apply if the item does not have the color prop.
|
@mdvacca did the change, please let me know what you think. |
|
Looks great, thanks! I'm landing the PR |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@mdvacca is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
This pull request was successfully merged by @cabelitos in 5b953e5. When will my fix make it into a release? | Upcoming Releases |
Summary
Since the Android's Picker implementation uses an ArrayAdapter,
it means that the views that were created may be reused for other items
in order to save memory. With this in mind, if one sets the Picker.Item
prop color for only certain items there might be an state that
some items that does not have the color set will end up appearing
with the wrong color. This happens because, this new item is
reusing a view of an item that had the color prop set.
In order to avoid this problem, once a new view is created
the ReactPickerAdapter will save the original color and
re-apply if the item does not have the color prop.
Changelog
[Android] [Fixed] - Picker.Item displays wrong colors
Test Plan
On android execute the code below. Only the FIRST item should be red.
Without the patch
You should see various items with the red color (when only the first one should be red)

With the patch
Only the first item is red.
Closes #25456