From fabfaff01059a86f186258a025873e11aebc4f16 Mon Sep 17 00:00:00 2001 From: Antoine Guenet Date: Mon, 15 Nov 2021 15:57:15 +0000 Subject: [PATCH] [FIX] web_editor: round px values converted from rem to 1 decimal place When converting an rem size to a pixel size, we sometimes ended up with values with many decimal places. This rounds them to one decimal place. X-original-commit: 8f8d5bf93f60560040a37695c3439600d5d88287 Part-of: odoo/odoo#81540 --- addons/web_editor/static/src/js/backend/convert_inline.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/backend/convert_inline.js b/addons/web_editor/static/src/js/backend/convert_inline.js index a2f55ccd6e5..41c6c835f35 100644 --- a/addons/web_editor/static/src/js/backend/convert_inline.js +++ b/addons/web_editor/static/src/js/backend/convert_inline.js @@ -788,7 +788,8 @@ function normalizeRem($editable) { const remMatch = node.getAttribute('style').match(/[\d\.]+\s*rem/g); for (const rem of remMatch || []) { const remValue = parseFloat(rem.replace(/[^\d\.]/g, '')); - node.setAttribute('style', node.getAttribute('style').replace(rem, remValue * rootFontSize + 'px')); + const pxValue = Math.round(remValue * rootFontSize * 10) / 10; + node.setAttribute('style', node.getAttribute('style').replace(rem, pxValue + 'px')); } } }