From 74f293e2fc85464845842c9bb57102157f8465c9 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Fri, 20 Nov 2020 10:33:33 +0300 Subject: [PATCH] Fixed #1678 - Chips is not working when the initial value sets 'null' --- src/components/chips/Chips.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/chips/Chips.js b/src/components/chips/Chips.js index 86ff058928..c2b9e836e6 100644 --- a/src/components/chips/Chips.js +++ b/src/components/chips/Chips.js @@ -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;