From 4310b11df534daecbf3ca49b01bd6fbad42d499f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Tue, 21 Aug 2018 16:13:29 +0200 Subject: [FIX] web: compute the correct height for textarea autoresize The box-sizing property was not correctly taken into account. - content-box is the standard behavior: border and padding are added after the height - border-box needs attention: border and padding must be included into the computed height Task: 1869469 PR: #26430 --- addons/web/static/src/js/core/dom.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'addons/web/static/src/js/core/dom.js') diff --git a/addons/web/static/src/js/core/dom.js b/addons/web/static/src/js/core/dom.js index 7e3cb6128b9..eaff2185de9 100644 --- a/addons/web/static/src/js/core/dom.js +++ b/addons/web/static/src/js/core/dom.js @@ -74,12 +74,12 @@ return { function resize() { $fixedTextarea.insertAfter($textarea); - var heightOffset; + var heightOffset = 0; var style = window.getComputedStyle($textarea[0], null); - if (style.boxSizing === 'content-box') { - heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)); - } else { - heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth); + if (style.boxSizing === 'border-box') { + var paddingHeight = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom); + var borderHeight = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth); + heightOffset = borderHeight + paddingHeight; } $fixedTextarea.width($textarea.width()); $fixedTextarea.val($textarea.val()); -- cgit v1.2.3