Permalink
Browse files

Fix onItemSelected firing for ReactPicker on initial layout.

Reviewed By: AaaChiuuu

Differential Revision: D3732557

fbshipit-source-id: ed031dbf205996dab8cb0555af972e6f26c0d202
  • Loading branch information...
1 parent 50e0d8e commit a2a8d7f5da93ee10cf5eccfb944f581f43cfe0c0 @donyu donyu committed with Facebook Github Bot 2 Aug 18, 2016
Showing with 4 additions and 0 deletions.
  1. +4 −0 ReactAndroid/src/main/java/com/facebook/react/views/picker/ReactPicker.java
@@ -79,6 +79,10 @@ public void requestLayout() {
public void setOnSelectListener(@Nullable OnSelectListener onSelectListener) {
if (getOnItemSelectedListener() == null) {
+ // onItemSelected gets fired immediately after layout because checkSelectionChanged() in
+ // AdapterView updates the selection position from the default INVALID_POSITION. To match iOS
+ // behavior, we don't want the event emitter for onItemSelected to fire right after layout.
+ mSuppressNextEvent = true;
setOnItemSelectedListener(
new OnItemSelectedListener() {
@Override

0 comments on commit a2a8d7f

Please sign in to comment.