Skip to content

Commit

Permalink
fix(map-widget): ensure map renders correctly when expanding initiall…
Browse files Browse the repository at this point in the history
…y collapsed sections (decaporg#6541)
  • Loading branch information
afieif committed Jun 12, 2024
1 parent cdd0899 commit 0955f5c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/decap-cms-widget-map/src/withMapControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function withMapControl({ getFormat, getMap } = {}) {
constructor(props) {
super(props);
this.mapContainer = React.createRef();
this.resizeObserver = null;
}

componentDidMount() {
Expand All @@ -69,6 +70,18 @@ export default function withMapControl({ getFormat, getMap } = {}) {
featuresSource.clear();
onChange(format.writeGeometry(feature.getGeometry(), writeOptions));
});

this.resizeObserver = new ResizeObserver(() => {
map.updateSize();
});

this.resizeObserver.observe(target);
}

componentWillUnmount() {
if (this.resizeObserver) {
this.resizeObserver.disconnect();
}
}

render() {
Expand All @@ -94,4 +107,4 @@ export default function withMapControl({ getFormat, getMap } = {}) {
);
}
};
}
}

0 comments on commit 0955f5c

Please sign in to comment.