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); + }); });