diff --git a/addons/web_editor/static/src/js/common/grid_layout_utils.js b/addons/web_editor/static/src/js/common/grid_layout_utils.js index 317895caaa1..09ac7abc260 100644 --- a/addons/web_editor/static/src/js/common/grid_layout_utils.js +++ b/addons/web_editor/static/src/js/common/grid_layout_utils.js @@ -2,7 +2,7 @@ import { renderToElement } from "@web/core/utils/render"; import {descendants, preserveCursor} from "@web_editor/js/editor/odoo-editor/src/utils/utils"; -const rowSize = 50; // 50px. +export const rowSize = 50; // 50px. // Maximum number of rows that can be added when dragging a grid item. export const additionalRowLimit = 10; 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 8f6df38a486..0600429acd0 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -865,7 +865,11 @@ var SnippetEditor = Widget.extend({ onDragStart: (args) => { this.dragStarted = true; const targetRect = this.$target[0].getBoundingClientRect(); - this.mousePositionYOnElement = args.y - targetRect.y; + // Bound the Y mouse position to the element height minus one + // grid row, to be able to drag from the bottom in a grid. + const gridRowSize = gridUtils.rowSize; + const boundedYMousePosition = Math.min(args.y, targetRect.bottom - gridRowSize); + this.mousePositionYOnElement = boundedYMousePosition - targetRect.y; this.mousePositionXOnElement = args.x - targetRect.x; this._onDragAndDropStart(args); },