diff --git a/umap/static/umap/js/modules/rendering/ui.js b/umap/static/umap/js/modules/rendering/ui.js index 72a3354a..f3971592 100644 --- a/umap/static/umap/js/modules/rendering/ui.js +++ b/umap/static/umap/js/modules/rendering/ui.js @@ -344,6 +344,10 @@ const PathMixin = { } options.pointerEvents = options.interactive ? 'visiblePainted' : 'stroke' this.parentClass.prototype.setStyle.call(this, options) + // TODO remove me when this gets merged and released: + // https://github.com/Leaflet/Leaflet/pull/9475 + + this._path.classList.toggle('leaflet-interactive', options.interactive) }, _redraw: function () { diff --git a/umap/tests/integration/test_view_polygon.py b/umap/tests/integration/test_view_polygon.py index f7462667..d30429cc 100644 --- a/umap/tests/integration/test_view_polygon.py +++ b/umap/tests/integration/test_view_polygon.py @@ -1,4 +1,5 @@ import re +from copy import deepcopy import pytest from playwright.sync_api import expect @@ -33,19 +34,9 @@ DATALAYER_DATA = { } -@pytest.fixture -def bootstrap(map, live_server): - map.settings["properties"]["zoom"] = 6 - map.settings["geometry"] = { - "type": "Point", - "coordinates": [8.429, 53.239], - } - map.save() +def test_should_open_popup_on_click(live_server, map, page): DataLayerFactory(map=map, data=DATALAYER_DATA) - - -def test_should_open_popup_on_click(live_server, map, page, bootstrap): - page.goto(f"{live_server.url}{map.get_absolute_url()}") + page.goto(f"{live_server.url}{map.get_absolute_url()}#6/53.239/8.429") polygon = page.locator("path").first expect(polygon).to_have_attribute("fill-opacity", "0.3") polygon.click() @@ -57,3 +48,12 @@ def test_should_open_popup_on_click(live_server, map, page, bootstrap): # Close popup page.locator("#map").click() expect(polygon).to_have_attribute("fill-opacity", "0.3") + + +def test_should_not_react_to_click_if_interactive_false(live_server, map, page): + data = deepcopy(DATALAYER_DATA) + data["features"][0]["properties"]["_umap_options"] = {"interactive": False} + DataLayerFactory(map=map, data=data) + page.goto(f"{live_server.url}{map.get_absolute_url()}#6/53.239/8.429") + polygon = page.locator("path").first + expect(polygon).to_have_css("pointer-events", "none")