Skip to content

Commit

Permalink
fix: hack to force reset layer list on collection changes
Browse files Browse the repository at this point in the history
  • Loading branch information
silvester-pari committed Sep 19, 2023
1 parent 66ebabb commit 5d8fa92
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions elements/layercontrol/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ export class EOxLayerControl extends LitElement {
@state()
optionalLayerArray: Array<BaseLayer>;

@state()
resizeObserver: ResizeObserver;
/**
* Hack to "force-reset" layer list
*/
private resetLayers = false;

/**
* The query selector for the map
Expand Down Expand Up @@ -95,7 +97,9 @@ export class EOxLayerControl extends LitElement {
"layerControlOptional",
true
);
this.requestUpdate();
setTimeout(() => {
this.requestUpdate();
});
}

private _emitLayerconfig(layer: Layer) {
Expand Down Expand Up @@ -210,7 +214,11 @@ export class EOxLayerControl extends LitElement {
) => {
layerCollection.on("change:length", () => {
if (!this._currentlySorting) {
this.resetLayers = true;
this._updateControl(layerCollection);
setTimeout(() => {
this.resetLayers = false;
});
}
});
};
Expand Down Expand Up @@ -313,7 +321,7 @@ export class EOxLayerControl extends LitElement {
layers: Array<BaseLayer>,
group?: string,
collection?: Collection<BaseLayer>
): TemplateResult => html`
): TemplateResult => this.resetLayers ? html`` : html`
<ul data-group="${group ?? nothing}">
${repeat(
layers,
Expand Down

0 comments on commit 5d8fa92

Please sign in to comment.