diff --git a/src/textswitch.js b/src/textswitch.js index 4e03c27a835b01c4555b83c1bc8f00d78e922fec..9b66beab64898aad40e306714285c0d391e243ce 100644 --- a/src/textswitch.js +++ b/src/textswitch.js @@ -12,7 +12,7 @@ const BUTTON2 = "button2"; * disabled: Disable the switch * * Events: - * change: emitted when the active name changes or the same button is clicked again + * change: when button is clicked * * Example: * <my-tag name="one" name1="one" name2="two" value1="One", value2="Two"></my-tag> @@ -63,22 +63,13 @@ export class TextSwitch extends LitElement { } update(changedProperties) { - this.name = this._active === BUTTON1 ? this.name1 : this.name2; - changedProperties.forEach((oldValue, propName) => { if (propName === "name") { if (this[propName] === this.name1) { this._active = BUTTON1; - } - if (this[propName] === this.name2) { + } else if (this[propName] === this.name2) { this._active = BUTTON2; } - } else if (propName === "_active") { - const event = new CustomEvent("change", { - bubbles: true, - cancelable: false, - }); - this.dispatchEvent(event); } }); @@ -87,15 +78,16 @@ export class TextSwitch extends LitElement { render() { const onClick = function (e) { - let new_id = e.target.id; - if (new_id === this._active) { - const event = new CustomEvent("change", { - bubbles: true, - cancelable: false, - }); - this.dispatchEvent(event); - } - this._active = new_id; + this._active = e.target.id; + this.name = this._active === BUTTON1 ? this.name1 : this.name2; + + // send event only when buttons are clicked + const event = new CustomEvent("change", { + bubbles: true, + cancelable: false, + }); + + this.dispatchEvent(event); }; return html` diff --git a/src/vpu-qualified-signature-pdf-upload.js b/src/vpu-qualified-signature-pdf-upload.js index dbeeadbfa8d1564bcce408d6149e6ea8a4767ab1..1ee035d4cfb5c06e8859a69ae8186c55455c5bfe 100644 --- a/src/vpu-qualified-signature-pdf-upload.js +++ b/src/vpu-qualified-signature-pdf-upload.js @@ -696,6 +696,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle <span class="headline">${i18n.t('qualified-pdf-upload.positioning')}:</span> <vpu-textswitch name1="auto" name2="manual" + name="${this.queuedFilesPlacementModes[id] ?? "auto"}" class="switch" value1="${i18n.t('qualified-pdf-upload.positioning-automatic')}" value2="${i18n.t('qualified-pdf-upload.positioning-manual')}"