@@ -21,7 +21,7 @@ export class UxChipInput implements Themable {
2121 public value : any = undefined ;
2222
2323 @bindable ( { defaultBindingMode : bindingMode . twoWay } )
24- public chipArray : Array < any > = new Array < any > ( ) ;
24+ public chipArray : Array < string > = new Array < string > ( ) ;
2525
2626 public view : View ;
2727 private textbox : HTMLInputElement ;
@@ -97,14 +97,22 @@ export class UxChipInput implements Themable {
9797 }
9898
9999 if ( key === 37 ) {
100- if ( this . chipArray . length ) {
101- this . textbox . value = this . chipArray . pop ( ) . toString ( ) ;
100+ if ( this . chipArray ) {
101+ const chip = this . chipArray . pop ( ) ;
102+
103+ if ( chip !== undefined ) {
104+ this . textbox . value = chip ;
105+ }
102106 }
103107 }
104108 }
105109
106110 public addChip ( ) {
107111 if ( this . textbox . value . length ) {
112+ if ( ! this . chipArray ) {
113+ this . chipArray = new Array < string > ( ) ;
114+ }
115+
108116 this . chipArray . push ( this . textbox . value ) ;
109117 this . textbox . value = '' ;
110118 this . chipsChanged ( ) ;
@@ -135,21 +143,21 @@ export class UxChipInput implements Themable {
135143 seperator = this . separator ;
136144 }
137145
138- if ( this . chipArray ) {
139- this . value = this . chipArray . join ( seperator ) ;
140- }
146+ this . value = this . chipArray . join ( seperator ) ;
141147 }
142148
143149 public valueChanged ( ) {
150+ if ( this . value === null ) {
151+ return ;
152+ }
153+
144154 let seperator = ', ' ;
145155
146156 if ( this . separator ) {
147157 seperator = this . separator ;
148158 }
149-
150- if ( this . value ) {
151- this . chipArray = this . value . split ( seperator ) ;
152- }
159+
160+ this . chipArray = this . value . split ( seperator ) ;
153161 }
154162
155163 public disabledChanged ( newValue : any ) {
0 commit comments