Merge pull request #1804 from umap-project/edit-layer-on-esc
fix: open edit panel when pressing ESC while drawing, if valid
This commit is contained in:
commit
5b4bf9d416
3 changed files with 13 additions and 0 deletions
|
@ -1326,6 +1326,7 @@ U.Editable = L.Editable.extend({
|
|||
// (eg. line has only one drawn point)
|
||||
// So let's check if the layer has no more shape
|
||||
if (!e.layer.hasGeom()) e.layer.del()
|
||||
else e.layer.edit()
|
||||
})
|
||||
// Layer for items added by users
|
||||
this.on('editable:drawing:cancel', (e) => {
|
||||
|
|
|
@ -83,6 +83,8 @@ def test_clicking_esc_should_finish_polygon(page, live_server, tilelayer):
|
|||
page.keyboard.press("Escape")
|
||||
expect(lines).to_have_count(1)
|
||||
expect(guide).to_have_count(0)
|
||||
# Should have opened edit form panel
|
||||
expect(page.locator(".panel").get_by_text("Feature properties")).to_be_visible()
|
||||
|
||||
|
||||
def test_clicking_esc_should_delete_polygon_if_empty(page, live_server, tilelayer):
|
||||
|
@ -106,6 +108,8 @@ def test_clicking_esc_should_delete_polygon_if_empty(page, live_server, tilelaye
|
|||
page.keyboard.press("Escape")
|
||||
expect(lines).to_have_count(0)
|
||||
expect(guide).to_have_count(0)
|
||||
# Should not have opened edit form panel
|
||||
expect(page.locator(".panel").get_by_text("Feature properties")).to_be_hidden()
|
||||
|
||||
|
||||
def test_clicking_esc_should_delete_polygon_if_invalid(page, live_server, tilelayer):
|
||||
|
@ -137,6 +141,8 @@ def test_clicking_esc_should_delete_polygon_if_invalid(page, live_server, tilela
|
|||
page.keyboard.press("Escape")
|
||||
expect(lines).to_have_count(0)
|
||||
expect(guide).to_have_count(0)
|
||||
# Should not have opened edit form panel
|
||||
expect(page.locator(".panel").get_by_text("Feature properties")).to_be_hidden()
|
||||
|
||||
|
||||
def test_can_draw_multi(live_server, page, tilelayer):
|
||||
|
|
|
@ -83,6 +83,8 @@ def test_clicking_esc_should_finish_line(page, live_server, tilelayer):
|
|||
page.keyboard.press("Escape")
|
||||
expect(lines).to_have_count(1)
|
||||
expect(guide).to_have_count(0)
|
||||
# Should have opened edit form panel
|
||||
expect(page.locator(".panel").get_by_text("Feature properties")).to_be_visible()
|
||||
|
||||
|
||||
def test_clicking_esc_should_delete_line_if_empty(page, live_server, tilelayer):
|
||||
|
@ -110,6 +112,8 @@ def test_clicking_esc_should_delete_line_if_empty(page, live_server, tilelayer):
|
|||
page.keyboard.press("Escape")
|
||||
expect(lines).to_have_count(0)
|
||||
expect(guide).to_have_count(0)
|
||||
# Should not have opened edit form panel
|
||||
expect(page.locator(".panel").get_by_text("Feature properties")).to_be_hidden()
|
||||
|
||||
|
||||
def test_clicking_esc_should_delete_line_if_invalid(page, live_server, tilelayer):
|
||||
|
@ -135,6 +139,8 @@ def test_clicking_esc_should_delete_line_if_invalid(page, live_server, tilelayer
|
|||
page.keyboard.press("Escape")
|
||||
expect(lines).to_have_count(0)
|
||||
expect(guide).to_have_count(0)
|
||||
# Should not have opened edit form panel
|
||||
expect(page.locator(".panel").get_by_text("Feature properties")).to_be_hidden()
|
||||
|
||||
|
||||
def test_can_draw_multi(live_server, page, tilelayer):
|
||||
|
|
Loading…
Reference in a new issue