Skip to content

Only create the last word if you paste a sentence with a valid delimiter #58

@igor-equals

Description

@igor-equals

If you paste a sentence like 'this, is, a, test' it will create only the word test as a chip.

 addChip = (value) => {
    if (this.props.uniqueChips && this.props.value.indexOf(value) !== -1) {
      this.setState({value: ""});
      return;
    }
    let chips = [...this.props.value, value]
    this.props.onChange(chips);
    this.setState({ value: "" })
  }

I belive that is caused by addChip being called on a loop and this.props.onChange(chips) is been executed asyncronous by the component using this component, so the props value does not change in time for the next iteration.

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