diff options
| author | Sébastien Theys <seb@odoo.com> | 2018-08-22 12:11:00 +0200 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2018-08-22 14:10:06 +0200 |
| commit | 416b810eb504df9cc1b3ec6d24fb921734c526a8 (patch) | |
| tree | f1e60009d35fc60e7c3da714d591ea50a77fb56c /addons/web/static/src | |
| parent | daec1d044029d9fcded1c066183a5cd817f25c32 (diff) | |
[FIX] web: prevent textarea vertical resize on chrome
Since we correctly compute the height of the field, we don't want to let the user resize it vertically.
This was already working on Firefox because it doesn't require the field to be in the DOM to read the resize attribute, but Chrome does require the field to already be in DOM.
Task: 1869469
PR: #26518
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/core/dom.js | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/addons/web/static/src/js/core/dom.js b/addons/web/static/src/js/core/dom.js index 1d82cea107f..060bb141eff 100644 --- a/addons/web/static/src/js/core/dom.js +++ b/addons/web/static/src/js/core/dom.js @@ -87,6 +87,18 @@ return { $textarea.css({height: Math.max(height + heightOffset, minHeight)}); } + function removeVerticalResize() { + // We already compute the correct height: + // we don't want the user to resize it vertically. + // On Chrome this needs to be called after the DOM is ready. + var style = window.getComputedStyle($textarea[0], null); + if (style.resize === 'vertical') { + $textarea[0].style.resize = 'none'; + } else if (style.resize === 'both') { + $textarea[0].style.resize = 'horizontal'; + } + } + options = options || {}; minHeight = (options && options.min_height) || 50; @@ -103,18 +115,16 @@ return { }).css(direction, -10000); $fixedTextarea.data("auto_resize", true); - var style = window.getComputedStyle($textarea[0], null); - if (style.resize === 'vertical') { - $textarea[0].style.resize = 'none'; - } else if (style.resize === 'both') { - $textarea[0].style.resize = 'horizontal'; - } resize(); + removeVerticalResize(); $textarea.data("auto_resize", true); $textarea.on('input focus change', resize); if (options.parent) { - core.bus.on('DOM_updated', options.parent, resize); + core.bus.on('DOM_updated', options.parent, function () { + resize(); + removeVerticalResize(); + }); } }, /** |
