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 b940cf14bd1..626b1bf6201 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 @@ -3,6 +3,8 @@ import {qweb} from 'web.core'; const rowSize = 50; // 50px. +// Maximum number of rows that can be added when dragging a grid item. +export const additionalRowLimit = 10; /** * Returns the grid properties: rowGap, rowSize, columnGap and columnSize. 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 13ef195afa9..58089c805be 100644 --- a/addons/web_editor/static/src/js/editor/snippets.editor.js +++ b/addons/web_editor/static/src/js/editor/snippets.editor.js @@ -1537,11 +1537,20 @@ var SnippetEditor = Widget.extend({ const dropzoneEl = this.dragState.dropzoneEl; const rowOverflow = Math.round((bottom - currentHeight) / (gridProp.rowSize + gridProp.rowGap)); const updateRows = bottom > currentHeight || bottom <= currentHeight && bottom > startingHeight; + const rowCount = Math.max(rowEl.dataset.rowCount, this.dragState.columnRowCount); + const maxRowEnd = rowCount + gridUtils.additionalRowLimit + 1; if (Math.abs(rowOverflow) >= 1 && updateRows) { - const dropzoneEnd = parseInt(dropzoneEl.style.gridRowEnd); - dropzoneEl.style.gridRowEnd = dropzoneEnd + rowOverflow; - backgroundGridEl.style.gridRowEnd = dropzoneEnd + rowOverflow; - this.dragState.currentHeight += rowOverflow * (gridProp.rowSize + gridProp.rowGap); + if (rowEnd <= maxRowEnd) { + const dropzoneEnd = parseInt(dropzoneEl.style.gridRowEnd); + dropzoneEl.style.gridRowEnd = dropzoneEnd + rowOverflow; + backgroundGridEl.style.gridRowEnd = dropzoneEnd + rowOverflow; + this.dragState.currentHeight += rowOverflow * (gridProp.rowSize + gridProp.rowGap); + } else { + // Don't add new rows if we have reached the limit. + dropzoneEl.style.gridRowEnd = maxRowEnd; + backgroundGridEl.style.gridRowEnd = maxRowEnd; + this.dragState.currentHeight = (maxRowEnd - 1) * (gridProp.rowSize + gridProp.rowGap) - gridProp.rowGap; + } } } });