From 6793a6bdc7d715f3e06a7781f662864273c90f48 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 7 Feb 2025 21:50:11 +0100 Subject: [PATCH 1/2] fix: do not modify schema while iterating on it --- umap/static/umap/js/modules/form/builder.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/umap/static/umap/js/modules/form/builder.js b/umap/static/umap/js/modules/form/builder.js index ea78a10f..01fe8bb8 100644 --- a/umap/static/umap/js/modules/form/builder.js +++ b/umap/static/umap/js/modules/form/builder.js @@ -142,13 +142,14 @@ export class MutatingForm extends Form { slugKey: 'PropertyInput', labelKey: 'PropertyInput', } - for (const [key, schema] of Object.entries(SCHEMA)) { - if (schema.type === Boolean) { + for (const [key, definition] of Object.entries(SCHEMA)) { + const schema = Utils.CopyJSON(definition) + if (definition.type === Boolean) { if (schema.nullable) schema.handler = 'NullableChoices' else schema.handler = 'Switch' - } else if (schema.type === 'Text') { + } else if (definition.type === 'Text') { schema.handler = 'Textarea' - } else if (schema.type === Number) { + } else if (definition.type === Number) { if (schema.step) schema.handler = 'Range' else schema.handler = 'IntInput' } else if (schema.choices) { From 64068af393f22c62752ff08a8f082b9f9edd2e1d Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 7 Feb 2025 21:50:36 +0100 Subject: [PATCH 2/2] fix: do not save "null" instead of null for showLabel --- umap/static/umap/js/modules/form/fields.js | 2 +- umap/static/umap/js/modules/schema.js | 2 +- umap/tests/integration/test_view_marker.py | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/modules/form/fields.js b/umap/static/umap/js/modules/form/fields.js index abbe8494..4a709e2e 100644 --- a/umap/static/umap/js/modules/form/fields.js +++ b/umap/static/umap/js/modules/form/fields.js @@ -1195,7 +1195,7 @@ Fields.NullableChoices = class extends Fields.TernaryChoices { this.properties.choices || [ [true, translate('always')], [false, translate('never')], - ['null', translate('hidden')], + [null, translate('hidden')], ] ) } diff --git a/umap/static/umap/js/modules/schema.js b/umap/static/umap/js/modules/schema.js index 3dacf79d..a6f279d5 100644 --- a/umap/static/umap/js/modules/schema.js +++ b/umap/static/umap/js/modules/schema.js @@ -450,7 +450,7 @@ export const SCHEMA = { choices: [ [true, translate('always')], [false, translate('never')], - ['null', translate('on hover')], + [null, translate('on hover')], ], }, slideshow: { diff --git a/umap/tests/integration/test_view_marker.py b/umap/tests/integration/test_view_marker.py index b9363d49..f5bff284 100644 --- a/umap/tests/integration/test_view_marker.py +++ b/umap/tests/integration/test_view_marker.py @@ -181,3 +181,13 @@ def test_only_visible_markers_are_added_to_dom(live_server, map, page): ) expect(markers).to_have_count(1) expect(tooltips).to_have_count(1) + + +def test_should_display_tooltip_on_hover(live_server, map, page, bootstrap): + map.settings["properties"]["showLabel"] = None + map.settings["properties"]["labelKey"] = "Foo {name}" + map.save() + page.goto(f"{live_server.url}{map.get_absolute_url()}") + expect(page.get_by_text("Foo test marker")).to_be_hidden() + page.locator(".leaflet-marker-icon").hover() + expect(page.get_by_text("Foo test marker")).to_be_visible()