React-select: Paste values

Created on 28 Aug 2018  路  9Comments  路  Source: JedWatson/react-select

Hi, Is there any way to paste values into the Multi-select text input?

categorquestion

Most helpful comment

I want to paste something like purple, Red, Ocean and React-select converted that into the tags.

All 9 comments

paste-values-multi

I want to paste something like purple, Red, Ocean and React-select converted that into the tags.

Okay I see; you'll need to take control of the value and inputValue. Something like:


class MySelect extends Component {
  onChange = (value) => {
    this.setState({ value });
  };
  onInputChange = (inputValue) => {
    this.setState({ inputValue }, () => {
      // logic for splitting on comma, and finding matching options
      const value = splitValue(inputValue);
      this.onChange(value)
    });
  };
  render() {
    return (
      <Select
        onInputChange={this.onInputChange}
        onChange={this.onChange}
        inputValue={this.state.inputValue}
        value={this.state.value}
      />
    );
  }
}

In the future, please don't file GitHub issues to ask questions. Use StackOverflow and tag your question with #react-select

updated

But something else, I'm using AsyncCreatable and when I paste something, first AsyncCreatable call my API and if is not exist I can add it.
Is there any way to when pasting something, ignore API call?

Mate, i'm not support. I'm just a guy that helps maintain this repo. I have a full-time job like you. Sorry...

Yes, Thanks :)

@omidnikrah

have you tried the allowCreateWhileLoading props?

@ThierryCols No, but I think it's not what I need. I wrote a tags input component from scratch.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mjuopperi picture mjuopperi  路  3Comments

coder-guy22296 picture coder-guy22296  路  3Comments

yrabinov picture yrabinov  路  3Comments

mbonaci picture mbonaci  路  3Comments

pablote picture pablote  路  3Comments