Skip to content
Snippets Groups Projects
Commit 164ed230 authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

textswitch: also emit a change event if the user clicks the same button again

Let the user of the component handle the duplicate change events
parent 4dc929a3
Branches
No related tags found
No related merge requests found
Pipeline #11307 passed
......@@ -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`
......
......@@ -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>
`);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment