diff --git a/src/textswitch.js b/src/textswitch.js index f3503f9e62888f8229c8b06015e352c140a767e1..7e025d26b5d764321bc68d771e8675193aeef7bb 100644 --- a/src/textswitch.js +++ b/src/textswitch.js @@ -8,11 +8,11 @@ const BUTTON2 = "button2"; * Attributes: * value1/value2: The values of the buttons * name1/name2: The names of the buttons - * name: Tshe active name + * name: The active name * disabled: Disable the switch * * Events: - * change: emitted when the active name changes + * change: emitted when the active name changes or the same button is clicked again * * Example: * <my-tag name="one" name1="one" name2="two" value1="One", value2="Two"></my-tag> @@ -87,7 +87,15 @@ export class TextSwitch extends LitElement { render() { const onClick = function (e) { - this._active = e.target.id; + 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; }; return html` diff --git a/src/vpu-qualified-signature-pdf-upload.js b/src/vpu-qualified-signature-pdf-upload.js index 5b7df195cc0822513caf864d3be23bfb6b0f1377..a6f21b823ce071d2a27045accf87157e517453ca 100644 --- a/src/vpu-qualified-signature-pdf-upload.js +++ b/src/vpu-qualified-signature-pdf-upload.js @@ -673,7 +673,7 @@ class QualifiedSignaturePdfUpload extends ScopedElementsMixin(VPUSignatureLitEle value1="${i18n.t('qualified-pdf-upload.positioning-automatic')}" value2="${i18n.t('qualified-pdf-upload.positioning-manual')}" ?disabled="${this.signingProcessEnabled}" - @click=${ (e) => this.queuePlacementSwitch(id, e.target.name) }></vpu-textswitch> + @change=${ (e) => this.queuePlacementSwitch(id, e.target.name) }></vpu-textswitch> </div> </div> `);