Skip to content

Commit 78b224c

Browse files
committed
fix(chips): remove last chip without freezing browser
resolves #60
1 parent 0132d7f commit 78b224c

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

src/chip-input/ux-chip-input.ts

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class UxChipInput implements Themable {
1515
@bindable public readonly: any = false;
1616
@bindable public theme = null;
1717
@bindable public type: any;
18-
@bindable public separator: string;
18+
@bindable public separator: string = ', ';
1919

2020
@bindable({ defaultBindingMode: bindingMode.twoWay })
2121
public value: any = undefined;
@@ -137,33 +137,13 @@ export class UxChipInput implements Themable {
137137
}
138138

139139
public chipsChanged() {
140-
let seperator = ', ';
140+
let chipValue: string | null = this.chips.join(this.separator);
141141

142-
if (this.separator) {
143-
seperator = this.separator;
142+
if (chipValue === '') {
143+
chipValue = null;
144144
}
145145

146-
this.value = this.chips.join(seperator);
147-
}
148-
149-
public valueChanged() {
150-
if (this.value === null) {
151-
return;
152-
}
153-
154-
let seperator = ', ';
155-
156-
if (this.separator) {
157-
seperator = this.separator;
158-
}
159-
160-
let newValue: string | null = this.chips.join(seperator);
161-
162-
if (newValue === '') {
163-
newValue = null;
164-
}
165-
166-
this.value = newValue;
146+
this.value = chipValue;
167147
}
168148

169149
public disabledChanged(newValue: any) {

0 commit comments

Comments
 (0)