Skip to content

Commit

Permalink
Merge pull request #5135 from nboisteault/popup_order
Browse files Browse the repository at this point in the history
Fix: order popups following layers order
  • Loading branch information
nboisteault authored Dec 18, 2024
2 parents bc87d1d + 40ad242 commit 68b4589
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 65 deletions.
3 changes: 2 additions & 1 deletion assets/src/modules/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export default class Popup {
const xCoord = evt?.xy?.x || evt?.pixel?.[0];
const yCoord = evt?.xy?.y || evt?.pixel?.[1];

let candidateLayers = this._lizmapState.rootMapGroup.findMapLayers().reverse();
// Order popups following layers order
let candidateLayers = this._lizmapState.rootMapGroup.findMapLayers().toSorted((a, b) => b.layerOrder - a.layerOrder);

// Only request visible layers
candidateLayers = candidateLayers.filter(layer => layer.visibility);
Expand Down
33 changes: 33 additions & 0 deletions tests/end2end/playwright/layer_order.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// @ts-check
import { test, expect } from '@playwright/test';
import { gotoMap } from './globals';

test.describe('Layer order', () => {

test('Layer order in map and popups', async ({ page }) => {
const url = '/index.php/view/map/?repository=testsrepository&project=layer_order';
await gotoMap(url, page);

// Assert layers order is as defined in QGIS
expect(await page.evaluate(() => lizMap.mainLizmap.map.getLayerByName('quartiers').getZIndex())).toEqual(0);
expect(await page.evaluate(() => lizMap.mainLizmap.map.getLayerByName('sousquartiers').getZIndex())).toEqual(1);
expect(await page.evaluate(() => lizMap.mainLizmap.map.getLayerByName('tramway_lines').getZIndex())).toEqual(2);
expect(await page.evaluate(() => lizMap.mainLizmap.map.getLayerByName('tramway_stops').getZIndex())).toEqual(3);

// Assert popups order is as defined in QGIS
await page.locator('#newOlMap').click({
position: {
x: 428,
y: 260
}
});

let popups = page.locator(".lizmapPopupSingleFeature");
await expect(popups).toHaveCount(4);

await expect(popups.nth(0)).toHaveAttribute("data-layer-id", "tramway_stops_437c64d6_adbb_4018_95d6_1f8f8cd6a81c");
await expect(popups.nth(1)).toHaveAttribute("data-layer-id", "tramway_lines_684f9541_dd3a_4f2d_9233_89f379413a18");
await expect(popups.nth(2)).toHaveAttribute("data-layer-id", "sousquartiers_274734f2_9aee_4acd_abaf_ba5692d1fd20");
await expect(popups.nth(3)).toHaveAttribute("data-layer-id", "quartiers_9226ee56_fa1c_44f8_8447_5be0815dd424");
});
});
Loading

2 comments on commit 68b4589

@3liz-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest weekly run of end2end "playwright" tests failed with this latest commit on the branch master 😣

CC @nboisteault and @Gustry, please have a look to the logs. Maybe it's a false positive ?

Visit https://github.com/3liz/lizmap-web-client/actions/runs/12460664000

@3liz-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The latest weekly run of end2end "cypress" tests failed with this latest commit on the branch master 😣

CC @nboisteault and @Gustry, please have a look to the logs. Maybe it's a false positive ?

Visit https://github.com/3liz/lizmap-web-client/actions/runs/12460664000

Please sign in to comment.