From 1419655e16215d0d3fc06b4274f006bb6caa2822 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 25 Nov 2022 17:14:56 +0000 Subject: [PATCH] [FIX] website: allow to exit fullscreen if not on website anymore While showcasing your website inside the website application, there is the possibility to hit the escape key to enter fullscreen (hiding the backend navbar outside edit mode and the editor panel during edit mode). There was a problem following this flow: - Go to your website inside your website app - Hit escape to enter fullscreen - Press CTRL-K to switch to another part of the backend => You are now somewhere in the backend, without the navbar (fullscreen) and you cannot exit it. As it was a one-line fix (except for the re-indentation), this commit now allows to exit fullscreen mode wherever we are. Discovered during task-3082439 X-original-commit: bd225ec782e26c87301e9e786ffd7250ad62ebfc Part-of: odoo/odoo#106735 --- .../website/static/src/services/website_service.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/addons/website/static/src/services/website_service.js b/addons/website/static/src/services/website_service.js index 2b6d4a0b8af..5c474c1d165 100644 --- a/addons/website/static/src/services/website_service.js +++ b/addons/website/static/src/services/website_service.js @@ -57,11 +57,15 @@ export const websiteService = { hotkey.add("escape", () => { // Toggle fullscreen mode when pressing escape. - if (currentWebsiteId) { - fullscreen = !fullscreen; - document.body.classList.toggle('o_website_fullscreen', fullscreen); - bus.trigger((fullscreen ? 'FULLSCREEN-INDICATION-SHOW' : 'FULLSCREEN-INDICATION-HIDE')); + if (!currentWebsiteId && !fullscreen) { + // Only allow to use this feature while on the website app, or + // while it is already fullscreen (in case you left the website + // app in fullscreen mode, thanks to CTRL-K). + return; } + fullscreen = !fullscreen; + document.body.classList.toggle('o_website_fullscreen', fullscreen); + bus.trigger(fullscreen ? 'FULLSCREEN-INDICATION-SHOW' : 'FULLSCREEN-INDICATION-HIDE'); }, { global: true }); registry.category('main_components').add('FullscreenIndication', { Component: FullscreenIndication,