Don't trigger selection-changed event if selection didn't change.
This commit is contained in:
parent
1e9ab0e01d
commit
64ba82fc9d
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@tp/tp-multi-toggle",
|
"name": "@tp/tp-multi-toggle",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "tp-multi-toggle.js",
|
"main": "tp-multi-toggle.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -80,7 +80,7 @@ class TpMultiToggle extends FormElement(LitElement) {
|
|||||||
onClick(e) {
|
onClick(e) {
|
||||||
const btn = closest(e.target, 'tp-button', true);
|
const btn = closest(e.target, 'tp-button', true);
|
||||||
|
|
||||||
if (btn) {
|
if (btn && !btn.hasAttribute('selected')) {
|
||||||
this.querySelectorAll('tp-button').forEach(el => el.removeAttribute('selected'));
|
this.querySelectorAll('tp-button').forEach(el => el.removeAttribute('selected'));
|
||||||
btn.setAttribute('selected', '');
|
btn.setAttribute('selected', '');
|
||||||
this.dispatchEvent(new CustomEvent('selection-changed', { detail: this.value, bubbles: true, composed: true }));
|
this.dispatchEvent(new CustomEvent('selection-changed', { detail: this.value, bubbles: true, composed: true }));
|
||||||
|
Loading…
Reference in New Issue
Block a user