Skip to content

Commit

Permalink
Prevent overlay container from scrolling on focus (#1286)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed Jan 7, 2021
1 parent 31ffe3c commit f3c091d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/static-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ type State = {
accessTokenInvalid: boolean
};

function preventScroll(event) {
event.target.scrollTo(0, 0);
}

export default class StaticMap extends PureComponent<StaticMapProps, State> {
static supported() {
return mapboxgl && mapboxgl.supported();
Expand Down Expand Up @@ -277,7 +281,12 @@ export default class StaticMap extends PureComponent<StaticMapProps, State> {
};
return (
<MapContext.Provider value={context}>
<div key="map-overlays" className="overlays" style={CONTAINER_STYLE}>
<div
key="map-overlays"
className="overlays"
style={CONTAINER_STYLE}
onScroll={preventScroll}
>
{this.props.children}
</div>
</MapContext.Provider>
Expand Down

0 comments on commit f3c091d

Please sign in to comment.