From af344710c2a4f28020d47dbf9d21db2822184834 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Thu, 2 Nov 2023 08:12:38 +0000 Subject: [PATCH] [FIX] web_editor: make the grid item drop more robust MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It happened previously that the grid item could be broken if `top` and `left` style properties were not set on it, which resulted in `NaN` values being used in the grid-area computation. This commit makes the drop more robust by obtaining their values through the computed style instead of the style. This way these properties are always defined. task-3554752 closes odoo/odoo#143903 X-original-commit: 7a8fd5792f9eedfebf812b15730259de2b511a58 Signed-off-by: Soukéina Bojabza (sobo) --- addons/web_editor/static/src/js/editor/snippets.editor.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/web_editor/static/src/js/editor/snippets.editor.js b/addons/web_editor/static/src/js/editor/snippets.editor.js index 455a5ab58ef..4b150084929 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -1358,8 +1358,9 @@ var SnippetEditor = Widget.extend({ // Defining the column grid area with its position. const gridProp = gridUtils._getGridProperties(rowEl); - const top = parseFloat(this.$target[0].style.top); - const left = parseFloat(this.$target[0].style.left); + const style = window.getComputedStyle(this.$target[0]); + const top = parseFloat(style.top); + const left = parseFloat(style.left); const rowStart = Math.round(top / (gridProp.rowSize + gridProp.rowGap)) + 1; const columnStart = Math.round(left / (gridProp.columnSize + gridProp.columnGap)) + 1;