From 8e7e9e5bf873173efd82508fb11e8a4ed1d7876b Mon Sep 17 00:00:00 2001 From: Dave Samojlenko Date: Thu, 7 Sep 2023 13:33:25 -0400 Subject: [PATCH] fix: Remove sub element parsing as it causes problems with long forms (#2626) * Comment out root id parsing code for now * Skip test * skip more tests --- components/form-builder/getPath.test.ts | 12 ++++++------ components/form-builder/getPath.ts | 11 ++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/form-builder/getPath.test.ts b/components/form-builder/getPath.test.ts index a495e3a881..be75a7b9a7 100644 --- a/components/form-builder/getPath.test.ts +++ b/components/form-builder/getPath.test.ts @@ -1,7 +1,7 @@ import { parseRootId, getElementIndexes, indexesToPath, getPath, getPathString } from "./getPath"; describe("Parse root ID", () => { - it("parses root id", () => { + it.skip("parses root id", () => { expect(parseRootId(1)).toEqual(1); expect(parseRootId(9)).toEqual(9); expect(parseRootId(12)).toEqual(12); @@ -14,12 +14,12 @@ describe("Parse root ID", () => { }); describe("Get array indexes for path by element ID", () => { - it("parses elIndex", () => { + it.skip("parses elIndex", () => { const elements = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 12 }]; expect(getElementIndexes(1210, elements)).toEqual([3, null]); }); - it("parses 3 digit elIndex and subIndex", () => { + it.skip("parses 3 digit elIndex and subIndex", () => { const elements = [ { id: 1 }, { id: 2, properties: { subElements: [{ id: 201 }, { id: 202 }, { id: 203 }] } }, @@ -31,7 +31,7 @@ describe("Get array indexes for path by element ID", () => { expect(subIndex).toEqual(0); }); - it("parses 4 digit elIndex and subIndex", () => { + it.skip("parses 4 digit elIndex and subIndex", () => { const elements = [ { id: 1 }, { id: 2 }, @@ -71,7 +71,7 @@ describe("Get path string by id", () => { expect(path).toEqual("form.elements[1].properties"); }); - it("gets subPath", async () => { + it.skip("gets subPath", async () => { const elements = [ { id: 1 }, { id: 2 }, @@ -97,7 +97,7 @@ describe("Get path string by id", () => { expect(path).toEqual(form.elements[3]); }); - it("gets sub element path", async () => { + it.skip("gets sub element path", async () => { const form = { elements: [ { id: 1 }, diff --git a/components/form-builder/getPath.ts b/components/form-builder/getPath.ts index 4cf38091f0..9c56b194dc 100644 --- a/components/form-builder/getPath.ts +++ b/components/form-builder/getPath.ts @@ -1,10 +1,11 @@ export const parseRootId = (id: number) => { + // @TODO: Revisit for sub elements. Note that the following will break if we have more than 99 sub elements // split 3 or 4 digit id into first 1 or 2 digits - const idStr = id.toString(); - const sliceAt = idStr.length == 3 ? 1 : 2; - const idArr = idStr.split(""); - const first = idArr.slice(0, sliceAt).join(""); - return Number(first); + // const idStr = id.toString(); + // const sliceAt = idStr.length == 3 ? 1 : 2; + // const idArr = idStr.split(""); + // const first = idArr.slice(0, sliceAt).join(""); + return Number(id); }; interface Form {