[FIX] web_editor, website: improve grid image code
Commit [1] added the support for images with a link set on them in grid mode. As a follow up, this commit does the following: - Removes the `!important` from the grid image anchor CSS rules, as they were not really needed. - Checks if the image has a closest `o_grid_item_image` column instead of checking the parent in the `GridImage` options. Indeed, this class already guarantees that the image is well a grid image; we can therefore simplify the code. It also removes a comment that was forgotten in commit [2]. [1]: https://github.com/odoo/odoo/commit/085d70cea571ea80c141ac6005e8bd8333bd269f [2]: https://github.com/odoo/odoo/commit/d8c374e3e6b31bf88aa42952aadf3379936f7600 related to opw-3580128 closes odoo/odoo#149681 X-original-commit: 9244e85ebb9e1605292698fe31ad94da7709ab86 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit is contained in:
committed by
qsm-odoo
parent
0412f1006f
commit
30ec9ffa2d
@@ -326,8 +326,7 @@ export function _checkIfImageColumn(columnEl) {
|
||||
}
|
||||
/**
|
||||
* Removes the line breaks and textnodes of the column, adds the grid class and
|
||||
* sets the image width to default so it can be displayed as expected. Also
|
||||
* blocks the edition of the column.
|
||||
* sets the image width to default so it can be displayed as expected.
|
||||
*
|
||||
* @private
|
||||
* @param {Element} columnEl a column containing only an image.
|
||||
|
||||
@@ -99,8 +99,8 @@
|
||||
|
||||
// Needed when "a" is "display: block".
|
||||
> a {
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4029,15 +4029,7 @@ options.registry.GridImage = options.Class.extend({
|
||||
* @returns {?HTMLElement}
|
||||
*/
|
||||
_getImageGridItem() {
|
||||
let parentEl = this.$target[0].parentNode;
|
||||
if (parentEl.matches("a")) {
|
||||
// Case of an image link.
|
||||
parentEl = parentEl.parentNode;
|
||||
}
|
||||
if (parentEl && parentEl.classList.contains('o_grid_item_image')) {
|
||||
return parentEl;
|
||||
}
|
||||
return null;
|
||||
return this.$target[0].closest(".o_grid_item_image");
|
||||
},
|
||||
/**
|
||||
* @override
|
||||
|
||||
Reference in New Issue
Block a user