diff --git a/src/renderer/src/stories/JSONSchemaForm.js b/src/renderer/src/stories/JSONSchemaForm.js index 1af50a2d0..86372e0a8 100644 --- a/src/renderer/src/stories/JSONSchemaForm.js +++ b/src/renderer/src/stories/JSONSchemaForm.js @@ -1417,12 +1417,18 @@ export class JSONSchemaForm extends LitElement { this.inputs = {}; } + #resolving; // Check if everything is internally rendered get rendered() { - const isRendered = resolve(this.#rendered, () => - Promise.all([...Object.values(this.forms), ...Object.values(this.tables)].map(({ rendered }) => rendered)) - ); - return isRendered; + if (this.#resolving) return this.#resolving; + this.#resolving = resolve(this.#rendered, () => { + const promise = Promise.all( + [...Object.values(this.forms), ...Object.values(this.tables)].map(({ rendered }) => rendered) + ); + promise.then(() => (this.#resolving = null)); + return promise; + }); + return this.#resolving; } render() { diff --git a/src/renderer/src/stories/SimpleTable.js b/src/renderer/src/stories/SimpleTable.js index 2fd49fd85..6d841bbb2 100644 --- a/src/renderer/src/stories/SimpleTable.js +++ b/src/renderer/src/stories/SimpleTable.js @@ -877,7 +877,8 @@ export class SimpleTable extends LitElement { } } - this.#onCellChange(cell); + this.#onCellChange(cell); // Only update data if the value has changed + this.#checkStatus(); // Check status after every validation update }, }); diff --git a/src/renderer/src/stories/pages/Page.js b/src/renderer/src/stories/pages/Page.js index 4eb7f3cc4..a8a0767d1 100644 --- a/src/renderer/src/stories/pages/Page.js +++ b/src/renderer/src/stories/pages/Page.js @@ -137,6 +137,7 @@ export class Page extends LitElement { if (desyncedData) { delete desyncedData[key]; if (Object.keys(desyncedData).length === 0) delete this.info.globalState.desyncedData; + await this.save({}, false); } } diff --git a/src/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js b/src/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js index b690a4e57..174676443 100644 --- a/src/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js +++ b/src/renderer/src/stories/pages/guided-mode/data/GuidedMetadata.js @@ -61,7 +61,6 @@ const tableRenderConfig = { }, UnitColumns: function (metadata) { metadata.editable = false; - console.log("Column metadata", metadata); metadata.schema.description = "Update unit information directly on your source data."; return true; @@ -184,12 +183,8 @@ export class GuidedMetadataPage extends ManagedPage { footer = { onNext: async () => { await this.save(); // Save in case the conversion fails - for (let { form } of this.forms) await form.validate(); // Will throw an error in the callback - - await this.convert({ preview: true }); - - return this.to(1); + return this.to(1); // Will trigger preview conversion if necessary }, }; @@ -323,9 +318,7 @@ export class GuidedMetadataPage extends ManagedPage { this.#checkAllLoaded(); }, - onUpdate: () => { - this.unsavedUpdates = "conversions"; - }, + onUpdate: () => (this.unsavedUpdates = "conversions"), validateOnChange, onlyRequired: false, diff --git a/src/renderer/src/stories/pages/guided-mode/options/GuidedStubPreview.js b/src/renderer/src/stories/pages/guided-mode/options/GuidedStubPreview.js index f66900cfc..39635033c 100644 --- a/src/renderer/src/stories/pages/guided-mode/options/GuidedStubPreview.js +++ b/src/renderer/src/stories/pages/guided-mode/options/GuidedStubPreview.js @@ -40,10 +40,7 @@ export class GuidedStubPreviewPage extends Page { next: "Run Conversion", onNext: async () => { await this.save(); // Save in case the conversion fails - - await this.convert(); - - return this.to(1); + return this.to(1); // Will trigger conversion if necessary }, }; diff --git a/src/renderer/src/stories/table/Cell.ts b/src/renderer/src/stories/table/Cell.ts index d554f8a62..414365b52 100644 --- a/src/renderer/src/stories/table/Cell.ts +++ b/src/renderer/src/stories/table/Cell.ts @@ -16,7 +16,7 @@ type ValidationResult = { type ValidationFunction = (value: any) => any | any[] -type OnValidateFunction = (info: ValidationResult) => void +type OnValidateFunction = (info: ValidationResult, changed?: boolean) => void type TableCellProps = { value: string, diff --git a/src/renderer/src/stories/table/cells/base.ts b/src/renderer/src/stories/table/cells/base.ts index 565818de0..cf9dbbe37 100644 --- a/src/renderer/src/stories/table/cells/base.ts +++ b/src/renderer/src/stories/table/cells/base.ts @@ -98,7 +98,7 @@ export class TableCellBase extends LitElement { this.editable = editable this.#editable.addEventListener('input', (ev: InputEvent) => { - this.interacted = true + if (ev.isTrusted) this.interacted = true if (ev.inputType.includes('history')) this.setText(this.#editable.innerText) // Catch undo / redo} }) @@ -160,7 +160,6 @@ export class TableCellBase extends LitElement { document.removeEventListener('click', this.#editableClose) } else { current = this.#editor.value - console.log('Editor value', current) this.interacted = true if (this.#editor && this.#editor.onEditEnd) this.#editor.onEditEnd() }