Skip to content

Problem setting initial value and label #3

@julianpensionjar

Description

@julianpensionjar

I'm trying to implement an autocomplete, preferably using the ModalDropdown, although FlatDropdown may also be acceptable if it makes a difference. This is wrapped in react-hook-form for control/validation, but I don't think that's the problem.

In the code below...
listValues is an array of objects with value/label attributes as per the examples.

Everything works ok, except:

  1. If I set the (initial) value to something (one of the "value" strings in the listValues object), then the item DOES seem to be pre-selected in the resulting dropdown, however the TextInput (in which the autocomplete occurs does NOT show the relevant label, and is instead blank.
  2. Furthermore, when the modal is opened (with the pre-selected option), there is no way to "confirm" the option and get the label to show in the TextInput. I am forced to pick another one, and then go back in again and select the first.

How can I get the relevant label to show in the TextInput when the value has been preset?

          <Autocomplete
              label={label}
              value={value}
              onBlur={onBlur}  //part of react-hook-form management
              onChange={onChange}  //part of react-hook-form management
              style={styles.input}
              error={hasError}  //part of react-hook-form management
              options={listValues}
              right={undefined}  //just to kill the right icon
            />

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