From b1f072cba4bfd18a196c5d9177187b70ace5b4e5 Mon Sep 17 00:00:00 2001 From: "Michael (mcm)" Date: Tue, 28 Jun 2022 07:57:14 +0000 Subject: [PATCH] [IMP] web: adapt dialog for mobile This commit modifies the dialog to make it more user friendly on small screen. On small screen, the dialog opens in fullscreen and saves the scroll position when opening to restore it on close. Part-of: odoo/odoo#92475 --- addons/web/static/src/core/dialog/dialog.js | 10 +++ addons/web/static/src/core/dialog/dialog.xml | 9 ++- .../static/src/core/dialog/dialog_service.js | 16 +++- .../tests/core/errors/error_service_tests.js | 2 + .../tests/mobile/mobile_form_view_tests.js | 76 +++++++++++++++++++ 5 files changed, 109 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/core/dialog/dialog.js b/addons/web/static/src/core/dialog/dialog.js index 0f2d75a0a44..f9bbefbc757 100644 --- a/addons/web/static/src/core/dialog/dialog.js +++ b/addons/web/static/src/core/dialog/dialog.js @@ -15,6 +15,16 @@ export class Dialog extends Component { }); this.id = `dialog_${this.data.id}`; useChildSubEnv({ inDialog: true, dialogId: this.id }); + + owl.onWillDestroy(() => { + if (this.env.isSmall) { + this.data.scrollToOrigin(); + } + }); + } + + get isFullscreen() { + return this.props.fullscreen || this.env.isSmall; } } Dialog.template = "web.Dialog"; diff --git a/addons/web/static/src/core/dialog/dialog.xml b/addons/web/static/src/core/dialog/dialog.xml index 048a104399f..9925618ea71 100644 --- a/addons/web/static/src/core/dialog/dialog.xml +++ b/addons/web/static/src/core/dialog/dialog.xml @@ -5,16 +5,21 @@