Skip to content

Commit

Permalink
Fix validation of groups
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettmflynn committed Jun 10, 2024
1 parent 2bc1b75 commit 80a5b47
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/electron/frontend/core/components/JSONSchemaForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,17 @@ export class JSONSchemaForm extends LitElement {
const groupEl = this.#getGroupElement(externalPath);

if (groupEl) {
groupEl.classList[resolvedErrors.length ? "add" : "remove"]("error");
groupEl.classList[warnings.length ? "add" : "remove"]("warning");

groupEl.setAttribute(`data-${externalPath}-errors`, updatedErrors.length);
groupEl.setAttribute(`data-${externalPath}-warnings`, updatedWarnings.length);

const allFormSections = groupEl.querySelectorAll(".form-section");
const inputs = Array.from(allFormSections).map((section) => section.id);
const allErrors = inputs.reduce((acc, id) => acc + parseInt(groupEl.getAttribute(`data-${id}-errors`)), 0);
const allWarnings = inputs.reduce((acc, id) => acc + parseInt(groupEl.getAttribute(`data-${id}-warnings`)), 0);

groupEl.classList[allErrors ? "add" : "remove"]("error");
groupEl.classList[allWarnings ? "add" : "remove"]("warning");
}

const clearAllErrors = isValid && updatedErrors.length === 0;
Expand Down

0 comments on commit 80a5b47

Please sign in to comment.