Skip to content

Commit

Permalink
fix: always unset editedFeature on editPanel close
Browse files Browse the repository at this point in the history
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!
  • Loading branch information
yohanboniface committed Oct 24, 2024
1 parent 023f48e commit 71b55e7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 3 additions & 1 deletion umap/static/umap/js/modules/rendering/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
},

Expand Down
13 changes: 12 additions & 1 deletion umap/static/umap/js/modules/ui/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || ''
}`
Expand Down Expand Up @@ -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
}
}
}
Expand All @@ -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 {
Expand Down

0 comments on commit 71b55e7

Please sign in to comment.