From 68a22a9177cab7f15de44a34fe5eb756d8daaa4e Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Thu, 18 Apr 2024 15:56:06 +0200 Subject: [PATCH] chore: redraw facets panel if open when changing facetKey --- umap/static/umap/js/modules/facets.js | 8 ++++++++ umap/static/umap/js/umap.js | 10 +++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/umap/static/umap/js/modules/facets.js b/umap/static/umap/js/modules/facets.js index f009ff06..c0b57086 100644 --- a/umap/static/umap/js/modules/facets.js +++ b/umap/static/umap/js/modules/facets.js @@ -51,6 +51,14 @@ export default class Facets { return properties } + redraw() { + if (this.isOpen()) this.open() + } + + isOpen() { + return !!document.querySelector('.umap-facet-search') + } + open() { const container = L.DomUtil.create('div', 'umap-facet-search') const title = L.DomUtil.add( diff --git a/umap/static/umap/js/umap.js b/umap/static/umap/js/umap.js index e61741ff..0f4f42f2 100644 --- a/umap/static/umap/js/umap.js +++ b/umap/static/umap/js/umap.js @@ -106,10 +106,13 @@ U.Map = L.Map.extend({ this.options.slideshow && this.options.slideshow.delay && this.options.slideshow.active === undefined - ) + ) { this.options.slideshow.active = true - if (this.options.advancedFilterKey) + } + if (this.options.advancedFilterKey) { this.options.facetKey = this.options.advancedFilterKey + delete this.options.advancedFilterKey + } // Global storage for retrieving datalayers and features this.datalayers = {} @@ -251,6 +254,7 @@ U.Map = L.Map.extend({ this.initCaptionBar() this.renderEditToolbar() this.renderControls() + this.facets.redraw() break case 'data': this.redrawVisibleDataLayers() @@ -1235,7 +1239,7 @@ U.Map = L.Map.extend({ [ 'options.facetKey', { - handler: 'Input', + handler: 'BlurInput', helpEntries: 'facetKey', placeholder: L._('Example: key1,key2|Label 2,key3|Label 3|checkbox'), label: L._('Facet keys'),