Fix loss of multi-text input value

This commit is contained in:
Sipke Schoorstra 2021-03-23 20:39:56 +01:00
parent 6374aa643b
commit 3ac97a0444
2 changed files with 5 additions and 2 deletions

View file

@ -256,6 +256,7 @@ declare namespace LocalJSX {
interface ElsaInputTags {
"fieldId"?: string;
"fieldName"?: string;
"onValueChanged"?: (event: CustomEvent<Array<string>>) => void;
"placeHolder"?: string;
"values"?: Array<string>;
}

View file

@ -1,4 +1,4 @@
import {Component, h, Prop, State} from '@stencil/core';
import {Component, h, Prop, Event, EventEmitter} from '@stencil/core';
@Component({
tag: 'elsa-input-tags',
@ -11,8 +11,9 @@ export class ElsaInputTags {
@Prop() fieldId?: string;
@Prop() placeHolder?: string = 'Add tag';
@Prop() values?: Array<string> = [];
@Event({bubbles: true}) valueChanged: EventEmitter<Array<string>>;
onInputKeyDown(e: KeyboardEvent) {
async onInputKeyDown(e: KeyboardEvent) {
if (e.key != "Enter")
return;
@ -28,6 +29,7 @@ export class ElsaInputTags {
values.push(value);
this.values = values.distinct();
input.value = '';
await this.valueChanged.emit(values);
}
onDeleteTagClick(e: Event, tag: string) {