Skip to content

Commit

Permalink
fix(questionnaire): answer not persisted
Browse files Browse the repository at this point in the history
* if two multiselect questions are right after each other the value was
no update due to a missing watch handler
  • Loading branch information
DanielHabenicht committed Feb 20, 2022
1 parent 666f0fb commit 62794fd
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Event, EventEmitter, h, Prop } from '@stencil/core';
import { Component, Event, EventEmitter, h, Prop, Watch } from '@stencil/core';

@Component({
styleUrl: 'input-multiple-choice.css',
Expand All @@ -10,6 +10,10 @@ export class InputMultipleChoice {
value: string;
text: string;
}[];
@Watch('options')
onOptionsChanged() {
this.updateFormDataHandler(this.inputId, this.getValue());
}
@Prop() value: string[] = undefined;

getValue(): string[] {
Expand All @@ -24,6 +28,7 @@ export class InputMultipleChoice {
// TODO: This Handler is called multiple times
this.updateFormData.emit({ key, value });
}

componentDidLoad() {
this.updateFormDataHandler(this.inputId, this.getValue());
}
Expand Down

0 comments on commit 62794fd

Please sign in to comment.