fix: fix path disappearing when changing its datalayer

fix #1931
This commit is contained in:
Yohan Boniface 2024-06-24 08:08:02 +02:00
parent 69c36a8f87
commit 8d9bd4aec1
2 changed files with 12 additions and 1 deletions

View file

@ -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')
},

View file

@ -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)