Skip to content

Commit 5399d00

Browse files
MV88Gnafu
authored andcommitted
Fix #1460 measure panel and tooltip translations (#1467)
* fixed measure panel and tooltip translations * added a test for measurementSupport for leaflet
1 parent 099b35a commit 5399d00

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

web/client/components/map/leaflet/MeasurementSupport.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ const MeasurementSupport = React.createClass({
3333
};
3434
},
3535
componentWillReceiveProps(newProps) {
36-
var drawingStrings = this.props.messages || (this.context.messages) ? this.context.messages.drawLocal : false;
37-
if (drawingStrings) {
38-
L.drawLocal = drawingStrings;
39-
}
40-
4136
if (newProps.measurement.geomType && newProps.measurement.geomType !== this.props.measurement.geomType ) {
4237
this.addDrawInteraction(newProps);
4338
}
@@ -66,6 +61,12 @@ const MeasurementSupport = React.createClass({
6661
}
6762
},
6863
render() {
64+
// moved here the translations because when language changes it is forced a render of this component. (see connect of measure plugin)
65+
var drawingStrings = this.props.messages || (this.context.messages ? this.context.messages.drawLocal : false);
66+
if (drawingStrings) {
67+
L.drawLocal = drawingStrings;
68+
}
69+
6970
return null;
7071
},
7172
updateMeasurementResults() {

web/client/components/map/leaflet/__tests__/MeasurementSupport-test.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ describe('Leaflet MeasurementSupport', () => {
4848
expect(cmp).toExist();
4949
});
5050

51+
it('test rendering', () => {
52+
let myMessages = {message: "message"};
53+
let drawLocal = L.drawLocal;
54+
L.drawLocal = null;
55+
const cmp = ReactDOM.render(
56+
<MeasurementSupport
57+
messages={myMessages}
58+
/>
59+
, msNode);
60+
expect(cmp).toExist();
61+
expect(L.drawLocal).toEqual(myMessages);
62+
// restoring old value of drawLocal because other test would fail otherwise.
63+
// L is global so drawLocal need to be restore to default value
64+
L.drawLocal = drawLocal;
65+
});
66+
5167
it('test if a new layer is added to the map in order to allow drawing.', () => {
5268
let map = L.map("map", {
5369
center: [51.505, -0.09],

web/client/plugins/Measure.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const MeasurePlugin = connect((state) => {
4141
};
4242
}, {
4343
toggleMeasure: changeMeasurement
44-
})(MeasureComponent);
44+
}, null, {pure: false})(MeasureComponent);
4545

4646
module.exports = {
4747
MeasurePlugin: assign(MeasurePlugin, {

0 commit comments

Comments
 (0)