Skip to content

Picker selects first item when selectValue is not in the list #1613

@kmcclive

Description

@kmcclive

Environment

  1. react-native -v: 0.51.0
  2. npm ls rnpm-plugin-windows: 0.2.8
  3. npm ls react-native-windows: 0.51.0-rc.1
  4. node -v: 8.9.4
  5. npm -v: 5.6.0
  6. yarn --version: 1.3.2

Then, specify:

  • Target Platform: UWP
  • Target Platform Version(s): 10.0.14393
  • Target Device(s): Desktop
  • Development Operating System: Windows
  • Visual Studio Version: 2017

Steps to Reproduce

  1. Add a Picker to a screen with one or more items in it.
  2. Set the selectedValue to a value that is not in the list.
  3. Run the app.

Expected Behavior

The text shown in the component (ComboBox) is empty/blank.

Actual Behavior

The text from the first item is displayed in the component (ComboBox). This also has the side effect of not displaying the correct text from the first item if the items change and the selected index doesn't.

Reproducible Demo

https://github.com/kmcclive/react-native-windows-picker-test

  1. Clone the repository.
  2. Restore packages: npm install
  3. Run the app: react-native run-windows
  4. Verify that "A" is displayed in the Picker even though the selectedValue is set to "D".

If you want to observe the side effect I mentioned, you can modify index.js to use App.js instead of App2.js, and verify that not all items are selected properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions