Skip to content

initialSelectedItem doesnt work #82

@stragz

Description

@stragz

Im trying to use your searchable dropdowns to create a form, it works fine on a new form but if you load one that saved partially filled I cannot seem to load the dropdown from a pre-determined value.

What I'm trying to do:
Load form with dropdown initial value set to Block.

How I'm trying to do it:
By using initialSelectedItem as described in Downshift documentation.

<MuiDownshift
   items={dataOptions}
  variant={"outlined"}
  onStateChange={handleStateChange}
  getInputProps={({ openMenu }) => ({
    label: "Storage Type",
    placeholder: "Select Storage Type"
  })}
  // initialSelectedItem={0}
  // initialSelectedItem={"0"}
  initialSelectedItem={"Block"}
  margin="normal"
/>

Expected result:
Form loads with with the the "Block" entry already selected in the dropdown

Result:
I've tried different ways to specify the value but none seem to work, I always end up with the Label.

Code Sandbox:
https://codesandbox.io/embed/vigorous-kalam-jzq4o

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions