From 1e2b8167ad3af204dc7de1240b4391b1513ddb42 Mon Sep 17 00:00:00 2001 From: apalanevich Date: Sun, 30 May 2021 12:25:14 +0300 Subject: [PATCH] fix(uip-setting): fix creating multiple setting's fields --- src/settings/setting/bool-setting/bool-setting.ts | 3 +++ src/settings/setting/select-setting/select-setting.ts | 4 +++- src/settings/setting/text-setting/text-setting.ts | 3 +++ src/settings/settings.ts | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/settings/setting/bool-setting/bool-setting.ts b/src/settings/setting/bool-setting/bool-setting.ts index 0635e757..ece9e655 100644 --- a/src/settings/setting/bool-setting/bool-setting.ts +++ b/src/settings/setting/bool-setting/bool-setting.ts @@ -17,6 +17,7 @@ export class UIPBoolSetting extends UIPSetting { protected connectedCallback() { super.connectedCallback(); + if (this.$field) return; this.$field = document.createElement('input'); this.$field.type = 'checkbox'; @@ -25,6 +26,8 @@ export class UIPBoolSetting extends UIPSetting { const label = document.createElement('label'); label.innerText = this.label; label.appendChild(this.$field); + + this.innerHTML = ''; this.appendChild(label); } diff --git a/src/settings/setting/select-setting/select-setting.ts b/src/settings/setting/select-setting/select-setting.ts index 3545f88b..e6429e19 100644 --- a/src/settings/setting/select-setting/select-setting.ts +++ b/src/settings/setting/select-setting/select-setting.ts @@ -23,6 +23,7 @@ export class UIPSelectSetting extends UIPSetting { protected connectedCallback() { super.connectedCallback(); + if (this.$field) return; this.$field = new ESLSelect(); this.$field.name = this.label; @@ -31,8 +32,9 @@ export class UIPSelectSetting extends UIPSetting { const label = document.createElement('label'); label.innerText = this.label; label.htmlFor = this.$field.$select.id; - this.appendChild(label); + + this.innerHTML = ''; this.appendChild(this.$field); } diff --git a/src/settings/setting/text-setting/text-setting.ts b/src/settings/setting/text-setting/text-setting.ts index 09d1e3cb..48bd92e3 100644 --- a/src/settings/setting/text-setting/text-setting.ts +++ b/src/settings/setting/text-setting/text-setting.ts @@ -11,6 +11,7 @@ export class UIPTextSetting extends UIPSetting { protected connectedCallback() { super.connectedCallback(); + if (this.$field) return; this.$field = document.createElement('input'); this.$field.type = 'text'; @@ -19,6 +20,8 @@ export class UIPTextSetting extends UIPSetting { const label = document.createElement('label'); label.innerText = this.label; label.appendChild(this.$field); + + this.innerHTML = ''; this.appendChild(label); } diff --git a/src/settings/settings.ts b/src/settings/settings.ts index 81dd6364..90e09df6 100644 --- a/src/settings/settings.ts +++ b/src/settings/settings.ts @@ -32,6 +32,7 @@ export class UIPSettings extends UIPPlugin { } protected _onSettingChanged(e: any) { + e.stopPropagation(); if (!this.root) return; (e.target as UIPSetting).applyTo(this.root.model);