Skip to content

Commit

Permalink
Fixed #1678 - Chips is not working when the initial value sets 'null'
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Nov 20, 2020
1 parent e164669 commit 74f293e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/chips/Chips.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,19 @@ export class Chips extends Component {

onKeyDown(event) {
const inputValue = event.target.value;
const values = this.props.value || [];

switch(event.which) {
//backspace
case 8:
if (this.inputElement.value.length === 0 && this.props.value && this.props.value.length > 0) {
this.removeItem(event, this.props.value.length - 1);
if (this.inputElement.value.length === 0 && values.length > 0) {
this.removeItem(event, values.length - 1);
}
break;

//enter
case 13:
if (inputValue && inputValue.trim().length && (!this.props.max || this.props.max > this.props.value.length)) {
if (inputValue && inputValue.trim().length && (!this.props.max || this.props.max > values.length)) {
this.addItem(event, inputValue, true);
}
break;
Expand Down

0 comments on commit 74f293e

Please sign in to comment.