@freenow/react-polygon-editor
Advanced tools
Comparing version
# Changelog | ||
## [1.1.0.rc3] - 12.03.2020 | ||
- Fix: Clear selection after import | ||
- Fix: Focus on polygon after import | ||
- Fix: Prevent default behaviour for keyevents | ||
## [1.1.0.rc2] - 11.03.2020 | ||
@@ -4,0 +10,0 @@ |
@@ -86,2 +86,3 @@ import React, { memo } from 'react'; | ||
this.props.setPolygon(coordinates); | ||
this.reframeOnPolygon(coordinates); | ||
}; | ||
@@ -233,2 +234,3 @@ this.handleImportPolygonActionClicked = () => { | ||
this.handleKeyDown = (e) => { | ||
e.preventDefault(); | ||
switch (e.key) { | ||
@@ -235,0 +237,0 @@ case 'Escape': |
@@ -12,5 +12,7 @@ import { SELECT_POINTS, ADD_POINT_TO_SELECTION, REMOVE_POINT_FROM_SELECTION, DESELECT_ALL_POINTS, SELECT_ALL_POINTS, MOVE_SELECTED_POINTS, DELETE_POLYGON_POINTS, ADD_POINT, ADD_POINT_TO_EDGE, CHANGE_POLYGON, SET_POLYGON } from './actions'; | ||
case SET_POLYGON: { | ||
const newPolygons = state.polygons.slice(); | ||
newPolygons[state.activeIndex] = action.payload; | ||
return Object.assign(Object.assign({}, state), { polygons: newPolygons }); | ||
return Object.assign(Object.assign({}, state), { polygons: [ | ||
...state.polygons.slice(0, state.activeIndex), | ||
action.payload, | ||
...state.polygons.slice(state.activeIndex + 1) | ||
], selection: new Set() }); | ||
} | ||
@@ -17,0 +19,0 @@ /////////////////////////////////////////////////////////////////////////////////// |
{ | ||
"name": "@freenow/react-polygon-editor", | ||
"version": "1.1.0-rc.2", | ||
"version": "1.1.0-rc.3", | ||
"description": "A react component for displaying and drawing geo polygons", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -41,2 +41,32 @@ import { getCenterCoordinate, movePolygonCoordinates, removeSelectedPoints } from '../helpers'; | ||
describe('set polygon', () => { | ||
it('should replace the active polygon', () => { | ||
const state: PolygonEditState = { | ||
activeIndex: 0, | ||
polygons: [POLYGON_ONE], | ||
selection: new Set() | ||
}; | ||
const expectedState: PolygonEditState = { | ||
activeIndex: 0, | ||
polygons: [POLYGON_TWO], | ||
selection: new Set() | ||
}; | ||
expect(polygonEditReducer(state, actions.setPolygon(POLYGON_TWO))).toEqual(expectedState); | ||
}); | ||
it('should remove any existing selection', () => { | ||
const state: PolygonEditState = { | ||
activeIndex: 0, | ||
polygons: [POLYGON_ONE], | ||
selection: new Set([0, 1, 2]) | ||
}; | ||
const expectedState: PolygonEditState = { | ||
activeIndex: 0, | ||
polygons: [POLYGON_TWO], | ||
selection: new Set() | ||
}; | ||
expect(polygonEditReducer(state, actions.setPolygon(POLYGON_TWO))).toEqual(expectedState); | ||
}); | ||
}); | ||
describe('Move points', () => { | ||
@@ -43,0 +73,0 @@ it('should move selected points', () => { |
@@ -37,7 +37,10 @@ import { | ||
case SET_POLYGON: { | ||
const newPolygons = state.polygons.slice(); | ||
newPolygons[state.activeIndex] = action.payload; | ||
return { | ||
...state, | ||
polygons: newPolygons | ||
polygons: [ | ||
...state.polygons.slice(0, state.activeIndex), | ||
action.payload, | ||
...state.polygons.slice(state.activeIndex + 1) | ||
], | ||
selection: new Set() | ||
}; | ||
@@ -44,0 +47,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
362723
0.48%7008
0.53%