Skip to content

Commit

Permalink
Fixing bug about the print overlay stacking (#5069)
Browse files Browse the repository at this point in the history
* FIX: Remove print overlay when change minidock
  • Loading branch information
neo-garaix authored Dec 3, 2024
1 parent 3cbd12f commit b0056cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions assets/src/components/Print.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
8 changes: 6 additions & 2 deletions assets/src/legacy/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
});
Expand Down
8 changes: 8 additions & 0 deletions tests/end2end/playwright/print.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit b0056cd

Please sign in to comment.