From 64ba82fc9daf5cc6e110b42eac24e220ddc5813a Mon Sep 17 00:00:00 2001 From: pk Date: Sun, 3 Sep 2023 21:31:42 +0200 Subject: [PATCH] Don't trigger selection-changed event if selection didn't change. --- package.json | 2 +- tp-multi-toggle.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 807daf8..bb9c284 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tp/tp-multi-toggle", - "version": "1.0.1", + "version": "1.1.0", "description": "", "main": "tp-multi-toggle.js", "scripts": { diff --git a/tp-multi-toggle.js b/tp-multi-toggle.js index 4137ef8..7a387aa 100644 --- a/tp-multi-toggle.js +++ b/tp-multi-toggle.js @@ -80,7 +80,7 @@ class TpMultiToggle extends FormElement(LitElement) { onClick(e) { const btn = closest(e.target, 'tp-button', true); - if (btn) { + if (btn && !btn.hasAttribute('selected')) { this.querySelectorAll('tp-button').forEach(el => el.removeAttribute('selected')); btn.setAttribute('selected', ''); this.dispatchEvent(new CustomEvent('selection-changed', { detail: this.value, bubbles: true, composed: true }));