diff --git a/umap/static/umap/js/umap.layer.js b/umap/static/umap/js/umap.layer.js index 2ca9ee62..4ab4462c 100644 --- a/umap/static/umap/js/umap.layer.js +++ b/umap/static/umap/js/umap.layer.js @@ -913,10 +913,10 @@ U.DataLayer = L.Evented.extend({ removeLayer: function (feature) { const id = L.stamp(feature) + this.layer.removeLayer(feature) feature.disconnectFromDataLayer(this) this._index.splice(this._index.indexOf(id), 1) delete this._layers[id] - this.layer.removeLayer(feature) delete this.map.features_index[feature.getSlug()] if (this.hasDataLoaded()) this.fire('datachanged') }, diff --git a/umap/tests/integration/test_edit_polygon.py b/umap/tests/integration/test_edit_polygon.py index 8ae4ca26..be65bb6a 100644 --- a/umap/tests/integration/test_edit_polygon.py +++ b/umap/tests/integration/test_edit_polygon.py @@ -120,3 +120,14 @@ def test_should_reset_style_on_cancel(live_server, openmap, page, bootstrap): page.once("dialog", lambda dialog: dialog.accept()) page.get_by_role("button", name="Cancel edits").click() expect(page.locator(".leaflet-overlay-pane path[fill='DarkBlue']")).to_have_count(1) + + +def test_can_change_datalayer(live_server, openmap, page, bootstrap): + other = DataLayerFactory( + name="Layer 2", map=openmap, settings={"color": "GoldenRod"} + ) + page.goto(f"{live_server.url}{openmap.get_absolute_url()}?edit") + expect(page.locator("path[fill='DarkBlue']")).to_have_count(1) + page.locator("path").click(modifiers=["Shift"]) + page.get_by_role("combobox").select_option(other.name) + expect(page.locator("path[fill='GoldenRod']")).to_have_count(1)