Skip to content

Commit

Permalink
avoid duplicate entry in creatable multi select text input
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush29 committed Jun 29, 2019
1 parent aabb6e3 commit e6e09e9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions docs/examples/CreatableInputOnly.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ export default class CreatableInputOnly extends Component<*, State> {
console.group('Value Added');
console.log(value);
console.groupEnd();
this.setState({
inputValue: '',
value: [...value, createOption(inputValue)],
});
const found = value.some(el => el.value === inputValue);
if(!found) {
this.setState({
inputValue: '',
value: [...value, createOption(inputValue)],
});
}
event.preventDefault();
}
};
Expand Down

0 comments on commit e6e09e9

Please sign in to comment.