Skip to content

Commit

Permalink
fix(uip-setting): fix creating multiple setting's fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Sisha0 committed May 30, 2021
1 parent bbe3be6 commit 1e2b816
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/settings/setting/bool-setting/bool-setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}

Expand Down
4 changes: 3 additions & 1 deletion src/settings/setting/select-setting/select-setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down
3 changes: 3 additions & 0 deletions src/settings/setting/text-setting/text-setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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);
}

Expand Down
1 change: 1 addition & 0 deletions src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1e2b816

Please sign in to comment.