From 45f001b9a8cf8610671a41be9c20c0ad2306b701 Mon Sep 17 00:00:00 2001 From: Bastian Guenther Date: Tue, 21 Jan 2025 18:07:10 +0100 Subject: [PATCH] [FIX] web_dialog_size: Fixed the issue that form view is changing its size when changing any field in the form --- .../static/src/js/web_dialog_size.esm.js | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/web_dialog_size/static/src/js/web_dialog_size.esm.js b/web_dialog_size/static/src/js/web_dialog_size.esm.js index ae2a8c771329..594408e9dc18 100644 --- a/web_dialog_size/static/src/js/web_dialog_size.esm.js +++ b/web_dialog_size/static/src/js/web_dialog_size.esm.js @@ -3,35 +3,49 @@ import {ActionDialog} from "@web/webclient/actions/action_dialog"; import {patch} from "@web/core/utils/patch"; import rpc from "web.rpc"; -import {Component, onMounted} from "@odoo/owl"; +import {Component, onWillRender} from "@odoo/owl"; import {Dialog} from "@web/core/dialog/dialog"; import {SelectCreateDialog} from "@web/views/view_dialogs/select_create_dialog"; export class ExpandButton extends Component { setup() { - this.last_size = this.props.getsize(); + this.lastSize = this.currentSize = this.props.getsize(); + this.sizeRestored = false; this.config = rpc.query({ model: "ir.config_parameter", method: "get_web_dialog_size_config", }); - onMounted(() => { + onWillRender(() => { var self = this; - this.config.then(function (r) { - if (r.default_maximize && stop) { - self.dialog_button_extend(); - } - }); + // If the form lost its current state, we need to set it again + if (this.props.getsize() !== this.currentSize) { + this.props.setsize(this.currentSize); + } + // Check if we already are in full screen or if the form was restored. + // If so we don't need to check the default maximize + if (this.props.getsize() !== "dialog_full_screen" && !this.sizeRestored) { + this.config.then(function (r) { + if (r.default_maximize && stop) { + self.dialog_button_extend(); + } + }); + } }); } dialog_button_extend() { + this.lastSize = this.props.getsize(); this.props.setsize("dialog_full_screen"); + this.currentSize = "dialog_full_screen"; + this.sizeRestored = false; this.render(); } dialog_button_restore() { - this.props.setsize(this.last_size); + this.props.setsize(this.lastSize); + this.currentSize = this.lastSize; + this.sizeRestored = true; this.render(); } }