mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
fix: make sure we sync a line when hitting esc while drawing (#2526)
I first tried to handle this on Leaflet.Editable side, to make it fire the "editable:edited" event we use to trigger the sync, but deciding what to do with a feature on escape needs some decisions that seems hard to implement in a generic way in Leaflet.Editable. We call stopDrawing, which then calls cancelDrawing, so here one need to decide if cancelDrawing should keep the already drawn line (but cancel the point being drawn) or cancel everything. This is why I end up making this change in uMap itself.
This commit is contained in:
commit
b1076dcb7b
2 changed files with 23 additions and 0 deletions
|
@ -699,6 +699,7 @@ U.Editable = L.Editable.extend({
|
|||
if (!event.layer.feature.hasGeom()) {
|
||||
event.layer.feature.del()
|
||||
} else {
|
||||
event.layer.feature.onCommit()
|
||||
event.layer.feature.edit()
|
||||
}
|
||||
})
|
||||
|
|
|
@ -609,3 +609,25 @@ def test_should_sync_saved_status(new_page, asgi_live_server, tilelayer):
|
|||
|
||||
# Peer A should not be in dirty state
|
||||
expect(peerA.locator("body")).not_to_have_class(re.compile(".*umap-is-dirty.*"))
|
||||
|
||||
|
||||
@pytest.mark.xdist_group(name="websockets")
|
||||
def test_should_sync_line_on_escape(new_page, asgi_live_server, tilelayer):
|
||||
map = MapFactory(name="sync", edit_status=Map.ANONYMOUS)
|
||||
map.settings["properties"]["syncEnabled"] = True
|
||||
map.save()
|
||||
|
||||
# Create two tabs
|
||||
peerA = new_page("Page A")
|
||||
peerA.goto(f"{asgi_live_server.url}{map.get_absolute_url()}?edit")
|
||||
peerB = new_page("Page B")
|
||||
peerB.goto(f"{asgi_live_server.url}{map.get_absolute_url()}?edit")
|
||||
|
||||
# Create a new marker from peerA
|
||||
peerA.get_by_title("Draw a polyline").click()
|
||||
peerA.locator("#map").click(position={"x": 220, "y": 220})
|
||||
peerA.locator("#map").click(position={"x": 200, "y": 200})
|
||||
peerA.locator("body").press("Escape")
|
||||
|
||||
expect(peerA.locator("path")).to_have_count(1)
|
||||
expect(peerB.locator("path")).to_have_count(1)
|
||||
|
|
Loading…
Reference in a new issue