From c94e38ca16993febee970bd8d20b3dd1be3eccaa Mon Sep 17 00:00:00 2001 From: luvi Date: Wed, 10 Aug 2022 13:16:59 +0000 Subject: [PATCH] [FIX] web: ImageField style This commit fixes the style of the field broken since the introduction of the "display: contents" rule in css. closes odoo/odoo#97906 Related: odoo/enterprise#30073 Signed-off-by: Samuel Degueldre --- .../src/views/fields/image/image_field.scss | 3 - .../src/views/fields/image/image_field.xml | 70 ++++++++++--------- .../src/views/form/form_controller.scss | 16 +++-- .../tests/views/fields/image_field_tests.js | 28 ++++---- 4 files changed, 59 insertions(+), 58 deletions(-) diff --git a/addons/web/static/src/views/fields/image/image_field.scss b/addons/web/static/src/views/fields/image/image_field.scss index 707dff2f5fa..8ea5752b32c 100644 --- a/addons/web/static/src/views/fields/image/image_field.scss +++ b/addons/web/static/src/views/fields/image/image_field.scss @@ -1,7 +1,4 @@ .o_field_image { - display: inline-block; - position: relative; - button { transition: opacity ease 400ms; width: 26px; diff --git a/addons/web/static/src/views/fields/image/image_field.xml b/addons/web/static/src/views/fields/image/image_field.xml index c9b33137221..beb7e5a4010 100644 --- a/addons/web/static/src/views/fields/image/image_field.xml +++ b/addons/web/static/src/views/fields/image/image_field.xml @@ -2,43 +2,45 @@ -
- - - +
+
+ + + +
+ Binary file
- Binary file
diff --git a/addons/web/static/src/views/form/form_controller.scss b/addons/web/static/src/views/form/form_controller.scss index 9d7989f977b..447f6329c51 100644 --- a/addons/web/static/src/views/form/form_controller.scss +++ b/addons/web/static/src/views/form/form_controller.scss @@ -428,14 +428,16 @@ $o-form-label-margin-right: 0px; // Avatar .oe_avatar { - float: right; - margin-bottom: 10px; + > div { + float: right; + margin-bottom: 10px; - > img { - max-width: $o-avatar-size; - max-height: $o-avatar-size; - vertical-align: top; - border: 1px solid $o-gray-300; + > img { + max-width: $o-avatar-size; + max-height: $o-avatar-size; + vertical-align: top; + border: 1px solid $o-gray-300; + } } } diff --git a/addons/web/static/tests/views/fields/image_field_tests.js b/addons/web/static/tests/views/fields/image_field_tests.js index 796e94f9281..983b5168b61 100644 --- a/addons/web/static/tests/views/fields/image_field_tests.js +++ b/addons/web/static/tests/views/fields/image_field_tests.js @@ -106,27 +106,27 @@ QUnit.module("Fields", (hooks) => { ); assert.containsOnce( target, - ".o_field_widget[name='document'] > img", + ".o_field_widget[name='document'] img", "the widget should contain an image" ); assert.strictEqual( - target.querySelector('div[name="document"] > img').dataset.src, + target.querySelector('div[name="document"] img').dataset.src, `data:image/png;base64,${MY_IMAGE}`, "the image should have the correct src" ); assert.hasClass( - target.querySelector(".o_field_widget[name='document'] > img"), + target.querySelector(".o_field_widget[name='document'] img"), "img-fluid", "the image should have the correct class" ); assert.hasAttrValue( - target.querySelector(".o_field_widget[name='document'] > img"), + target.querySelector(".o_field_widget[name='document'] img"), "width", "90", "the image should correctly set its attributes" ); assert.strictEqual( - target.querySelector(".o_field_widget[name='document'] > img").style.maxWidth, + target.querySelector(".o_field_widget[name='document'] img").style.maxWidth, "90px", "the image should correctly set its attributes" ); @@ -167,7 +167,7 @@ QUnit.module("Fields", (hooks) => { }); assert.strictEqual( - target.querySelector('div[name="document"] > img').dataset.src, + target.querySelector('div[name="document"] img').dataset.src, "data:image/png;base64,incorrect_base64_value", "the image has the invalid src by default" ); @@ -175,7 +175,7 @@ QUnit.module("Fields", (hooks) => { // As GET requests can't occur in tests, we must generate an error // on the img element to check whether the data-src is replaced with // a placeholder, here knowing that the GET request would fail - await triggerEvent(target, 'div[name="document"] > img', "error"); + await triggerEvent(target, 'div[name="document"] img', "error"); assert.hasClass( target.querySelector('.o_field_widget[name="document"]'), @@ -184,27 +184,27 @@ QUnit.module("Fields", (hooks) => { ); assert.containsOnce( target, - ".o_field_widget[name='document'] > img", + ".o_field_widget[name='document'] img", "the widget should contain an image" ); assert.strictEqual( - target.querySelector('div[name="document"] > img').dataset.src, + target.querySelector('div[name="document"] img').dataset.src, "/web/static/img/placeholder.png", "the image should have the correct src" ); assert.hasClass( - target.querySelector(".o_field_widget[name='document'] > img"), + target.querySelector(".o_field_widget[name='document'] img"), "img-fluid", "the image should have the correct class" ); assert.hasAttrValue( - target.querySelector(".o_field_widget[name='document'] > img"), + target.querySelector(".o_field_widget[name='document'] img"), "width", "90", "the image should correctly set its attributes" ); assert.strictEqual( - target.querySelector(".o_field_widget[name='document'] > img").style.maxWidth, + target.querySelector(".o_field_widget[name='document'] img").style.maxWidth, "90px", "the image should correctly set its attributes" ); @@ -237,7 +237,7 @@ QUnit.module("Fields", (hooks) => { }); assert.strictEqual( - target.querySelector('div[name="document"] > img').dataset.src, + target.querySelector('div[name="document"] img').dataset.src, "data:image/png;base64,coucou==", "the image should have the initial src" ); @@ -263,7 +263,7 @@ QUnit.module("Fields", (hooks) => { // Wait for a render await nextTick(); assert.strictEqual( - target.querySelector("div[name=document] > img").dataset.src, + target.querySelector("div[name=document] img").dataset.src, `data:image/png;base64,${MY_IMAGE}`, "the image should have the new src" );