From 86cb228df444ab6554553ebb550ff3802d82798a Mon Sep 17 00:00:00 2001 From: Faustino Kialungila Date: Sun, 19 Jan 2020 20:52:19 +0100 Subject: [PATCH] Trim wysiwyg text to avoid misalignment on Firefox (#454) --- src/element/textWysiwyg.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/element/textWysiwyg.tsx b/src/element/textWysiwyg.tsx index ecc2be023..10f25c338 100644 --- a/src/element/textWysiwyg.tsx +++ b/src/element/textWysiwyg.tsx @@ -10,6 +10,12 @@ type TextWysiwygParams = { onSubmit: (text: string) => void; }; +// When WYSIWYG text ends with white spaces, the text gets vertically misaligned +// in order to fix this issue, we remove those white spaces +function trimText(text: string) { + return text.trim(); +} + export function textWysiwyg({ initText, x, @@ -77,7 +83,7 @@ export function textWysiwyg({ function handleSubmit() { if (editable.innerText) { - onSubmit(editable.innerText); + onSubmit(trimText(editable.innerText)); } cleanup(); }