From 71b55e7759b230eb36a9f354b26e827a99f8e0d8 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 24 Oct 2024 19:22:46 +0200 Subject: [PATCH] fix: always unset editedFeature on editPanel close And only this panel. This was creating a weird bug, steps to reproduce: - create a marker - shift-click on the marker to edit the layer (so without explicitly closing the panel) - try to type the layer name: the panel would close This is also because currently the schema and render() are too dump, and when any `name` is changed then the `data` reflow is called, while it should not when editing the datalayer name. We want to: - have more targeted schema - have more specific reflow in render But that's for other PRs! --- umap/static/umap/js/modules/rendering/ui.js | 4 +++- umap/static/umap/js/modules/ui/panel.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/umap/static/umap/js/modules/rendering/ui.js b/umap/static/umap/js/modules/rendering/ui.js index b496a544..c01d309e 100644 --- a/umap/static/umap/js/modules/rendering/ui.js +++ b/umap/static/umap/js/modules/rendering/ui.js @@ -32,7 +32,9 @@ const FeatureMixin = { if (map.editedFeature === this.feature) { this.feature._marked_for_deletion = true this.feature.endEdit() - map.editPanel.close() + if (map.editedFeature === this.feature) { + map.editPanel.close() + } } }, diff --git a/umap/static/umap/js/modules/ui/panel.js b/umap/static/umap/js/modules/ui/panel.js index 6fa77e60..ec6dd530 100644 --- a/umap/static/umap/js/modules/ui/panel.js +++ b/umap/static/umap/js/modules/ui/panel.js @@ -25,6 +25,9 @@ export class Panel { } open({ content, className, actions = [] } = {}) { + if (this.isOpen()) { + this.onClose() + } this.container.className = `with-transition panel window ${this.className} ${ this.mode || '' }` @@ -71,10 +74,13 @@ export class Panel { close() { document.body.classList.remove(`panel-${this.className.split(' ')[0]}-on`) + this.onClose() + } + + onClose() { if (DomUtil.hasClass(this.container, 'on')) { DomUtil.removeClass(this.container, 'on') this.map.invalidateSize({ pan: false }) - this.map.editedFeature = null } } } @@ -84,6 +90,11 @@ export class EditPanel extends Panel { super(map) this.className = 'right dark' } + + onClose() { + super.onClose() + this.map.editedFeature = null + } } export class FullPanel extends Panel {