Skip to content

Using setEntryText or setting a typeahead's entryValue state variable with a ref/from outside the typeahead component has unwanted side effects #181

Open
@vrunjeti

Description

@vrunjeti

I'm trying to set the value of the typeahead's input, but doing so with setEntryText or setting its entryValue state also renders the dropdown with one option containing the chosen value.

The solution suggested in #116 works for setting the input's value, but doing so also displayed the dropdown containing one option with that value. This brought up further issues with trying to manually blur the input. Unlike the solution from #169, which depends on re-rendering the typeahead component from the top, in this case, calling typeahead.setEntryText or setting its entryValue state variable seems to also trigger something that causes the results dropdown to be displayed.

What I'm wondering is if this coupling was intentional, and if so, why. I would imagine that most people trying to use setEntryText would want to do just that and not have any side effects.

After some more digging around, I found that @yurynix's suggestion from #74 achieves what I'm trying to do with no side effects. Even though this worked for me, I'm still curious about setEntryText's side effects, especially since it doesn't appear to be mentioned in the docs.

Sorry for all these words, I'm just trying to get a better understanding and hopefully help others find solutions to similar problems. Thanks!

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