From 796cb061d032fea9250ab2863d381192aacd0262 Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Thu, 4 Jan 2024 12:38:05 +0000 Subject: [PATCH] [FIX] web: enable zoom tooltip for ImageField in edit mode Steps to reproduce ================== - Set the zoom option on an image field (You can do it with studio starting from 16.3) - Go to a record and hover over the image => Nothing happens Cause of the issue ================== The tooltip is only displayed in readonly, but with https://github.com/odoo/odoo/pull/100570 , the readonly mode has been removed. So it only applies for views with the readonly attribute. Solution ======== Always display the tooltip opw-3646005 closes odoo/odoo#148534 X-original-commit: e0f9a7eedfb91ea46969490cf261548835844907 Signed-off-by: Hubert Van De Walle Signed-off-by: Francois Georis (fge) --- .../static/src/views/fields/image/image_field.js | 2 +- .../static/tests/views/fields/image_field_tests.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/views/fields/image/image_field.js b/addons/web/static/src/views/fields/image/image_field.js index b92e14089ed..a027048f310 100644 --- a/addons/web/static/src/views/fields/image/image_field.js +++ b/addons/web/static/src/views/fields/image/image_field.js @@ -88,7 +88,7 @@ export class ImageField extends Component { } get hasTooltip() { return ( - this.props.enableZoom && this.props.readonly && this.props.record.data[this.props.name] + this.props.enableZoom && this.props.record.data[this.props.name] ); } get tooltipAttributes() { 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 988c7bb2664..1eb40703f67 100644 --- a/addons/web/static/tests/views/fields/image_field_tests.js +++ b/addons/web/static/tests/views/fields/image_field_tests.js @@ -517,7 +517,8 @@ QUnit.module("Fields", (hooks) => { }); QUnit.test("ImageField: zoom and zoom_delay options (edit)", async function (assert) { - serverData.models.partner.records[0].document = MY_IMAGE; + serverData.models.partner.records[0].document = "3 kb"; + serverData.models.partner.records[0].write_date = "2022-08-05 08:37:00"; await makeView({ type: "form", @@ -531,8 +532,15 @@ QUnit.module("Fields", (hooks) => { }); assert.ok( - !target.querySelector(".o_field_image img").dataset["tooltipInfo"], - "the tooltip is not present in edition" + JSON.parse( + target.querySelector(".o_field_image img").dataset["tooltipInfo"] + ).url.endsWith("/web/image?model=partner&id=1&field=document&unique=1659688620000"), + "tooltip show the full image from the field value" + ); + assert.strictEqual( + target.querySelector(".o_field_image img").dataset["tooltipDelay"], + "600", + "tooltip has the right delay" ); });