Skip to content

Set default value when input is empty to ComboBox? #2789

Discussion options

You must be logged in to vote

I got it working for my real app but this fake demo doesn't show it the 1st time,i.e, on reload even though I have selected defaultSelectedKey just like in my real app.

Anyways, here's the Codesandbox → https://codesandbox.io/s/combobox-with-fzf-496ub?file=/src/App.tsx

The main logic is in the onBlur plus a bunch of other things to make it work:

const onBlur = (e: any) => {
    const tz = e.target.value;
    if (!timezonesList.map((item) => item.key).includes(tz)) {
      setInputValue(defaultTz); // here it should be actual database value
    }
  };

Thanks, @LFDanLu & @reidbarber for the help 🙌

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
4 replies
@deadcoder0904
Comment options

@deadcoder0904
Comment options

@reidbarber
Comment options

@deadcoder0904
Comment options

Comment options

You must be logged in to vote
2 replies
@deadcoder0904
Comment options

@deadcoder0904
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by deadcoder0904
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants