diff --git a/src/element/subtypes/mathjax/implementation.tsx b/src/element/subtypes/mathjax/implementation.tsx index 3e12c6b1e..a3830bc88 100644 --- a/src/element/subtypes/mathjax/implementation.tsx +++ b/src/element/subtypes/mathjax/implementation.tsx @@ -668,7 +668,7 @@ const measureMarkup = ( } document.body.removeChild(container); let width = 0; - let height = 0; + let height = measureText(" ", font, lineHeight).height; childMetrics.forEach((metrics) => (width += metrics.width)); childMetrics.forEach( (metrics) => (height = Math.max(height, metrics.height)), diff --git a/src/element/subtypes/mathjax/tests/implementation.test.tsx b/src/element/subtypes/mathjax/tests/implementation.test.tsx index 9aae70ff1..95a827bc2 100644 --- a/src/element/subtypes/mathjax/tests/implementation.test.tsx +++ b/src/element/subtypes/mathjax/tests/implementation.test.tsx @@ -18,4 +18,30 @@ describe("mathjax", () => { const metrics2 = measureTextElement(elements[1]); expect(metrics1).toStrictEqual(metrics2); }); + it("minimum height remains", async () => { + await render(); + await ensureSubtypesLoaded(["math"]); + const elements = [ + API.createElement({ type: "text", id: "A", text: "a" }), + API.createElement({ + type: "text", + id: "B", + text: "\\(\\alpha\\)", + subtype: "math", + customData: { useTex: true }, + }), + API.createElement({ + type: "text", + id: "C", + text: "`beta`", + subtype: "math", + customData: { useTex: false }, + }), + ]; + const height = measureTextElement(elements[0]).height; + const height1 = measureTextElement(elements[1]).height; + const height2 = measureTextElement(elements[2]).height; + expect(height).toEqual(height1); + expect(height).toEqual(height2); + }); });