diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index d0749a81..d9fbf737 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -65,9 +65,8 @@ U.FeatureMixin = { }, view: function (e) { - if (this.map.editEnabled) return - const outlink = this.getOption('outlink'), - target = this.getOption('outlinkTarget') + const outlink = this.getOption('outlink') + const target = this.getOption('outlinkTarget') if (outlink) { switch (target) { case 'self': @@ -77,19 +76,31 @@ U.FeatureMixin = { window.top.location = outlink break default: - const win = window.open(this.properties._umap_options.outlink) + window.open(this.properties._umap_options.outlink) } return } // TODO deal with an event instead? - if (this.map.slideshow) this.map.slideshow.current = this + if (this.map.slideshow) { + this.map.slideshow.current = this + } this.map.currentFeature = this this.attachPopup() - this.openPopup((e && e.latlng) || this.getCenter()) + this.openPopup(e?.latlng || this.getCenter()) + }, + + render: function (fields) { + const impactData = fields.some((field) => { + return field.startsWith('properties.') + }) + if (impactData) { + if (this.map.currentFeature === this) { + this.view() + } + } }, openPopup: function () { - if (this.map.editEnabled) return this.parentClass.prototype.openPopup.apply(this, arguments) }, diff --git a/umap/tests/integration/test_edit_marker.py b/umap/tests/integration/test_edit_marker.py index fb3b2d1a..731de01c 100644 --- a/umap/tests/integration/test_edit_marker.py +++ b/umap/tests/integration/test_edit_marker.py @@ -82,6 +82,19 @@ def test_should_open_an_edit_toolbar_on_click(live_server, openmap, page, bootst expect(page.get_by_role("link", name="Delete this feature")).to_be_visible() +def test_should_update_open_popup_on_edit(live_server, openmap, page, bootstrap): + page.goto(f"{live_server.url}{openmap.get_absolute_url()}") + expect(page.locator(".umap-icon-active")).to_be_hidden() + page.locator(".leaflet-marker-icon").click() + expect(page.locator(".leaflet-popup-content-wrapper")).to_be_visible() + expect(page.get_by_role("heading", name="test marker")).to_be_visible() + expect(page.get_by_text("Some description")).to_be_visible() + page.get_by_role("button", name="Edit").click() + page.locator(".leaflet-marker-icon").click(modifiers=["Shift"]) + page.locator('input[name="name"]').fill("test marker edited") + expect(page.get_by_role("heading", name="test marker edited")).to_be_visible() + + def test_should_follow_datalayer_style_when_changing_datalayer( live_server, openmap, page ):