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 (#6541) (#7229)

* fix(map-widget): ensure map renders correctly when expanding initially collapsed sections (#6541)

* fix: newlline lint

---------

Co-authored-by: Martin Jagodic <[email protected]>
  • Loading branch information
afieif and martinjagodic authored Jun 26, 2024
1 parent 7483f19 commit 041e34e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions 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 Down

0 comments on commit 041e34e

Please sign in to comment.