Skip to content

Commit

Permalink
fix: use resizeobserver in order to support firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
silvester-pari committed Dec 18, 2024
1 parent e3de0b1 commit a46cf52
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions elements/layercontrol/src/components/layer-legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,15 @@ export class EOxLayerControlLayerLegend extends LitElement {
return this.noShadow ? this : super.createRenderRoot();
}

updated() {
if (
!this.layerLegend.width &&
this.offsetWidth < 325 &&
this.offsetWidth !== this.layerLegend.width
) {
this.layerLegend.width = this.offsetWidth;
this.requestUpdate();
firstUpdated() {
// if the width is explicitly set, don't auto-update
if (!this.layerLegend.width) {
new ResizeObserver(() => {
if (this.offsetWidth !== this.layerLegend.width) {
this.layerLegend.width = this.offsetWidth;
this.requestUpdate();
}
}).observe(this.renderRoot.querySelector(".legend-container"));
}
}

Expand Down

0 comments on commit a46cf52

Please sign in to comment.