diff --git a/web/client/components/mapcontrols/scale/ScaleBox.jsx b/web/client/components/mapcontrols/scale/ScaleBox.jsx index e3c780bda7..39333c2303 100644 --- a/web/client/components/mapcontrols/scale/ScaleBox.jsx +++ b/web/client/components/mapcontrols/scale/ScaleBox.jsx @@ -45,7 +45,7 @@ class ScaleBox extends React.Component { } onComboChange = (event) => { - var selectedZoomLvl = parseInt(event.nativeEvent.target.value, 10); + let selectedZoomLvl = parseInt(event.nativeEvent.target.value, 10); this.props.onChange(selectedZoomLvl, this.props.scales[selectedZoomLvl]); }; @@ -58,14 +58,15 @@ class ScaleBox extends React.Component { }; render() { - var control = null; + let control = null; + const currentZoomLvl = Math.round(this.props.currentZoomLvl); if (this.props.readOnly) { control = - + ; } else if (this.props.useRawInput) { control = - ( {this.getOptions()} ) ; @@ -73,7 +74,7 @@ class ScaleBox extends React.Component { control = (
{this.props.label} - + {this.getOptions()}
) diff --git a/web/client/components/mapcontrols/scale/__tests__/ScaleBox-test.jsx b/web/client/components/mapcontrols/scale/__tests__/ScaleBox-test.jsx index 2ba5a5ef4b..5368dde32e 100644 --- a/web/client/components/mapcontrols/scale/__tests__/ScaleBox-test.jsx +++ b/web/client/components/mapcontrols/scale/__tests__/ScaleBox-test.jsx @@ -96,4 +96,10 @@ describe('ScaleBox', () => { expect(domLabel).toExist(); expect(domLabel.innerHTML).toContain("Scale:"); }); + + it('should support not rounded zoom levels', () => { + TestUtils.act(() => { ReactDOM.render(, document.getElementById('container')); }); + const select = document.querySelector('select'); + expect(select.value).toBe('5'); + }); });