From 1b497e8bfce0e6967f20986c2b65f4a61cb51cf5 Mon Sep 17 00:00:00 2001 From: Nicolas Olmos Date: Wed, 24 Dec 2025 11:03:56 -0300 Subject: [PATCH 1/4] fix: replace hidden html string for empty string --- src/components/inputs/formik-text-editor.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/inputs/formik-text-editor.js b/src/components/inputs/formik-text-editor.js index 5cc4d0dc9..a54b928d0 100644 --- a/src/components/inputs/formik-text-editor.js +++ b/src/components/inputs/formik-text-editor.js @@ -11,7 +11,12 @@ const FormikTextEditor = ({ name, ...props }) => { name={name} id={name} value={values[name]} - onChange={(e) => setFieldValue(name, e.target.value)} + onChange={(e) => { + const stringValue = + e.target.value === "


" ? "" : e.target.value; + + setFieldValue(name, stringValue); + }} onBlur={() => setFieldTouched(name, true)} error={touched?.[name] && errors?.[name] ? errors?.[name] : ""} license={process.env.JODIT_LICENSE_KEY} From 0bb6fa472aa4deeff57503979669138db2dd1aec Mon Sep 17 00:00:00 2001 From: Nicolas Olmos Date: Mon, 19 Jan 2026 10:59:09 -0300 Subject: [PATCH 2/4] chore: create helper that covers all cases of empty strings --- src/components/inputs/utils/normalizeJoditEmpty.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/components/inputs/utils/normalizeJoditEmpty.js diff --git a/src/components/inputs/utils/normalizeJoditEmpty.js b/src/components/inputs/utils/normalizeJoditEmpty.js new file mode 100644 index 000000000..9816d54e5 --- /dev/null +++ b/src/components/inputs/utils/normalizeJoditEmpty.js @@ -0,0 +1,6 @@ +const normalizeJoditEmpty = (textInput) => { + const doc = new DOMParser().parseFromString(textInput, "text/html"); + return doc.body.textContent.length === 0 ? "" : textInput; +}; + +export default normalizeJoditEmpty; From 2404791d9467cb36ed07445ca22a2f0a5bd650e3 Mon Sep 17 00:00:00 2001 From: Nicolas Olmos Date: Mon, 19 Jan 2026 10:59:32 -0300 Subject: [PATCH 3/4] chore: test helper --- .../utils/__tests__/normalizeJoditEmpty.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/components/inputs/utils/__tests__/normalizeJoditEmpty.test.js diff --git a/src/components/inputs/utils/__tests__/normalizeJoditEmpty.test.js b/src/components/inputs/utils/__tests__/normalizeJoditEmpty.test.js new file mode 100644 index 000000000..fe9e66ec6 --- /dev/null +++ b/src/components/inputs/utils/__tests__/normalizeJoditEmpty.test.js @@ -0,0 +1,14 @@ +import { expect, describe, it } from "@jest/globals"; +import normalizeJoditEmpty from "../normalizeJoditEmpty"; + +describe("normalizeJoditEmpty", () => { + it("normalizes an empty string that is surrounded by html tags", () => { + const inputString = "


"; + expect(normalizeJoditEmpty(inputString)).toBe(""); + }); + + it("normalizes a string with content is returned without modifications", () => { + const inputString = "

This is a content strign

"; + expect(normalizeJoditEmpty(inputString)).toBe(inputString); + }); +}); From a970529252e3c2974a6a4b9e3327e575ffd840bd Mon Sep 17 00:00:00 2001 From: Nicolas Olmos Date: Mon, 19 Jan 2026 11:01:36 -0300 Subject: [PATCH 4/4] chore: replace validation with the helper --- src/components/inputs/formik-text-editor.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/inputs/formik-text-editor.js b/src/components/inputs/formik-text-editor.js index a54b928d0..346fb23cb 100644 --- a/src/components/inputs/formik-text-editor.js +++ b/src/components/inputs/formik-text-editor.js @@ -1,6 +1,7 @@ import React from "react"; import TextEditorV3 from "openstack-uicore-foundation/lib/components/inputs/editor-input-v3"; import { useFormikContext } from "formik"; +import normalizeJoditEmpty from "./utils/normalizeJoditEmpty"; const FormikTextEditor = ({ name, ...props }) => { const { values, errors, touched, setFieldValue, setFieldTouched } = @@ -12,8 +13,7 @@ const FormikTextEditor = ({ name, ...props }) => { id={name} value={values[name]} onChange={(e) => { - const stringValue = - e.target.value === "


" ? "" : e.target.value; + const stringValue = normalizeJoditEmpty(e.target.value); setFieldValue(name, stringValue); }}