diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js index 7f588a1dee7..1d0e1e39e6c 100644 --- a/addons/website/static/src/js/editor/snippets.options.js +++ b/addons/website/static/src/js/editor/snippets.options.js @@ -1041,7 +1041,7 @@ options.registry.layout_column = options.Class.extend({ */ _computeWidgetState: function (methodName, params) { if (methodName === 'selectCount') { - return '' + this.$target.children().length; + return '' + (this.colsLength || this.$target.children().length); } return this._super(...arguments); }, @@ -1059,6 +1059,7 @@ options.registry.layout_column = options.Class.extend({ this.trigger_up('request_history_undo_record', {$target: this.$target}); + var colsLength = this.$target.children().length + count; if (count > 0) { var $lastColumn = this.$target.children().last(); for (var i = 0; i < count; i++) { @@ -1071,17 +1072,18 @@ options.registry.layout_column = options.Class.extend({ }); } - this._resizeColumns(); + this._resizeColumns(colsLength); this.trigger_up('cover_update'); }, /** * Resizes the columns so that they are kept on one row. * * @private + * @param {number} [colsLength] (default to the actual number of columns) */ - _resizeColumns: function () { + _resizeColumns: function (colsLength) { var $columns = this.$target.children(); - var colsLength = $columns.length; + colsLength = colsLength || $columns.length; var colSize = Math.floor(12 / colsLength) || 1; var colOffset = Math.floor((12 - colSize * colsLength) / 2); var colClass = 'col-lg-' + colSize; @@ -1093,6 +1095,9 @@ options.registry.layout_column = options.Class.extend({ if (colOffset) { $columns.first().addClass('offset-lg-' + colOffset); } + // TODO: remove in master. This is used to keep the UI in sync, but + // won't be needed once option methods are properly asynchronous. + this.colsLength = colsLength; }, });