From 10110bd4e43cfe9937298a052427f5052fc732ea Mon Sep 17 00:00:00 2001 From: std-odoo Date: Tue, 1 Aug 2023 10:15:38 +0000 Subject: [PATCH] [IMP] web: allow to disable the popover re-position MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Purpose ======= When the DOM changes, we recompute the popover position. This is useful for most popovers, but when we have a form inside the popover (like the properties definition) it can be very annoying to move the form while the user fills it. Task-3380176 closes odoo/odoo#128983 Signed-off-by: Warnon Aurélien (awa) --- addons/web/static/src/core/popover/popover.js | 8 +++++ .../web/static/src/core/popover/popover.xml | 2 +- .../src/core/popover/popover_service.js | 1 + addons/web/static/src/core/position_hook.js | 7 ++++ .../fields/properties/properties_field.js | 1 + .../tests/core/popover/popover_tests.js | 33 +++++++++++++++++++ 6 files changed, 51 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/core/popover/popover.js b/addons/web/static/src/core/popover/popover.js index 9ed194afcd7..8c929ca9082 100644 --- a/addons/web/static/src/core/popover/popover.js +++ b/addons/web/static/src/core/popover/popover.js @@ -11,6 +11,7 @@ export class Popover extends Component { onPositioned: this.props.onPositioned || this.onPositioned.bind(this), position: this.props.position, popper: "ref", + fixedPosition: this.props.fixedPosition, }); } onPositioned(el, { direction, variant }) { @@ -35,6 +36,9 @@ export class Popover extends Component { // reset all arrow classes const arrowEl = el.querySelector(".popover-arrow"); + if (!arrowEl) { + return; + } arrowEl.className = "popover-arrow"; switch (position) { case "tm": // top-middle @@ -98,6 +102,10 @@ Popover.props = { type: Function, optional: true, }, + fixedPosition: { + type: Boolean, + optional: true, + }, target: { validate: (target) => { // target may be inside an iframe, so get the Element constructor diff --git a/addons/web/static/src/core/popover/popover.xml b/addons/web/static/src/core/popover/popover.xml index 9e4fe0f15ff..ed2341c8e7f 100644 --- a/addons/web/static/src/core/popover/popover.xml +++ b/addons/web/static/src/core/popover/popover.xml @@ -4,7 +4,7 @@