[FIX] web_editor: fix the widget state of the Vertical Alignment option
Since commit [1], an `align-items-start` class is added when going from grid mode to normal mode in order to always have one of the four choices of the Vertical Alignment option selected. Indeed, without this class, none of them are chosen. However, only a few snippets have this option and it is therefore not possible to modify this class easily in the snippets that do not have it (except removing it from the DOM manually). The real issue in fact comes from the computation of this option widget state, which should select the last button (so the `align-items-stretch` one) if no class is present, since the behaviors are equivalent in these two situations. This commit removes the addition of this `align-items-start` class and fixes the `_computeWidgetState` of the Vertical Alignment option. [1]: https://github.com/odoo/odoo/commit/cc406afcea7bf5846233a9f97a4a8ac5f618f3ec task-3142615 closes odoo/odoo#113949 X-original-commit: 75ef0d5d7ed000cf55b47bebb00cc2d0bb34b581 Signed-off-by: Vray Benjamin (bvr) <bvr@odoo.com>
This commit is contained in:
@@ -5311,9 +5311,6 @@ registry.layout_column = SnippetOptionWidget.extend({
|
||||
}
|
||||
// Removing the grid properties.
|
||||
delete rowEl.dataset.rowCount;
|
||||
|
||||
// Adding back an align-items-* class.
|
||||
rowEl.classList.add('align-items-start');
|
||||
},
|
||||
/**
|
||||
* Removes the padding highlights that were added when changing the grid
|
||||
@@ -5329,6 +5326,22 @@ registry.layout_column = SnippetOptionWidget.extend({
|
||||
},
|
||||
});
|
||||
|
||||
registry.vAlignment = SnippetOptionWidget.extend({
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
async _computeWidgetState(methodName, params) {
|
||||
const value = await this._super(...arguments);
|
||||
if (methodName === 'selectClass' && !value) {
|
||||
// If there is no `align-items-` class on the row, then the `align-
|
||||
// items-stretch` class is selected, because the behaviors are
|
||||
// equivalent in both situations.
|
||||
return 'align-items-stretch';
|
||||
}
|
||||
return value;
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
* Allows snippets to be moved before the preceding element or after the following.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user