From 5c7a24d48f771bb8d2665c2601ecfc1779e93056 Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Tue, 21 Nov 2023 15:46:02 -0600 Subject: [PATCH] Properly set input --- src/renderer/src/stories/JSONSchemaInput.js | 7 ++++++- src/renderer/src/stories/Search.js | 7 +------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/renderer/src/stories/JSONSchemaInput.js b/src/renderer/src/stories/JSONSchemaInput.js index b51f16732..41a6dd368 100644 --- a/src/renderer/src/stories/JSONSchemaInput.js +++ b/src/renderer/src/stories/JSONSchemaInput.js @@ -112,7 +112,10 @@ export class JSONSchemaInput extends LitElement { // onValidate = () => {} updateData(value, forceValidate = false) { + if (this.value !== value && !forceValidate) { + + // Update the actual input element const el = this.getElement(); if (el.type === "checkbox") el.checked = value; else if (el.classList.contains("list")) @@ -121,7 +124,8 @@ export class JSONSchemaInput extends LitElement { return { value }; }) : []; - else el.value = value; + else if (el instanceof Search) el.shadowRoot.querySelector("input").value = value; + else el.value = value } const { path: fullPath } = this; @@ -157,6 +161,7 @@ export class JSONSchemaInput extends LitElement { this.value = value; // Update the latest value this.#activateTimeoutValidation(name, path); + }; #triggerValidation = (name, path) => { diff --git a/src/renderer/src/stories/Search.js b/src/renderer/src/stories/Search.js index d22fd8ee8..e75e5dc94 100644 --- a/src/renderer/src/stories/Search.js +++ b/src/renderer/src/stories/Search.js @@ -174,7 +174,6 @@ export class Search extends LitElement { options: { type: Object }, showAllWhenEmpty: { type: Boolean }, listMode: { type: String, reflect: true }, - value: { type: String, reflect: true }, }; } @@ -187,6 +186,7 @@ export class Search extends LitElement { }); this.#initialize(); + } onSelect = (id, value) => {}; @@ -220,11 +220,6 @@ export class Search extends LitElement { #sortedCategories = []; #populate = (input) => { - // Hide all if empty - if (!input) { - this.#initialize(); - return; - } const toShow = [];