From b0056cd97466ecd5cef01d74bdc76e282c3abf13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A9o?= <92678879+neo-garaix@users.noreply.github.com> Date: Tue, 3 Dec 2024 17:43:48 +0100 Subject: [PATCH] Fixing bug about the print overlay stacking (#5069) * FIX: Remove print overlay when change minidock --- assets/src/components/Print.js | 3 +++ assets/src/legacy/map.js | 8 ++++++-- tests/end2end/playwright/print.spec.js | 8 ++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/assets/src/components/Print.js b/assets/src/components/Print.js index 4c76311435..cc48e99999 100644 --- a/assets/src/components/Print.js +++ b/assets/src/components/Print.js @@ -107,6 +107,9 @@ export default class Print extends HTMLElement { mainLizmap.map.getView().on('change:resolution', this._onChangeResolution); render(this._template(), this); + } else if (e.navElements.includes('print nav-minidock active')) { // Remove print overlay when clicking on another minidock + mainLizmap.map.removeToolLayer(this._maskLayer); + mainLizmap.map.getView().un('change:resolution', this._onChangeResolution); } }, minidockclosed: (e) => { diff --git a/assets/src/legacy/map.js b/assets/src/legacy/map.js index 2414972956..764cf8bf0a 100644 --- a/assets/src/legacy/map.js +++ b/assets/src/legacy/map.js @@ -3898,7 +3898,11 @@ window.lizMap = function() { const dockContentSelector = dockType == 'minidock' ? '#mini-dock-content > div' : '#' + dockType + '-content > div'; - document.querySelectorAll('#mapmenu .nav-' + dockType).forEach(element => element.classList.remove('active')); + let navElements = []; + document.querySelectorAll('#mapmenu .nav-' + dockType).forEach(element => { + navElements.push(element.className); + element.classList.remove('active'); + }); document.querySelectorAll(dockContentSelector).forEach(element => element.classList.add('hide')); parentElement.classList.toggle('active', !wasActive); if (dockId) { @@ -3908,7 +3912,7 @@ window.lizMap = function() { const dockEvent = dockType == 'right-dock' ? 'rightdock' : dockType; const lizmapEvent = wasActive ? dockEvent + 'closed' : dockEvent + 'opened'; - lizMap.events.triggerEvent(lizmapEvent, { 'id': dockId }); + lizMap.events.triggerEvent(lizmapEvent, { 'id': dockId, 'navElements': navElements}); return false; }); diff --git a/tests/end2end/playwright/print.spec.js b/tests/end2end/playwright/print.spec.js index 6f56c4ea27..bf7eec2507 100644 --- a/tests/end2end/playwright/print.spec.js +++ b/tests/end2end/playwright/print.spec.js @@ -710,4 +710,12 @@ test.describe('Error while printing', () => { await expect(page.locator("#message > div:last-child")).toHaveClass(/alert-danger/); }); + + test('Remove print overlay when switching to another minidock', async ({ page }) => { + await page.locator('#button-print').click(); + + await page.locator('#button-selectiontool').click(); + + await expect(page.locator('.ol-unselectable > canvas')).toHaveCount(0); + }); });