Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Bug] fix update dataId not update layer data (#1414)
Shan He119c89332320
diff --git a/src/components/side-panel/panel-toggle.js b/src/components/side-panel/panel-toggle.jsindex b5978d19e..8572ebaa7 100644--- a/src/components/side-panel/panel-toggle.js+++ b/src/components/side-panel/panel-toggle.js@@ -85,6 +85,6 @@ const PanelToggleFactory = () => {PanelToggle.propTypes = propTypes;return PanelToggle;-};+}export default PanelToggleFactory;diff --git a/src/reducers/vis-state-updaters.js b/src/reducers/vis-state-updaters.jsindex ebad8014d..a6d343fcd 100644--- a/src/reducers/vis-state-updaters.js+++ b/src/reducers/vis-state-updaters.js@@ -270,8 +270,8 @@ export function layerConfigChangeUpdater(state, action) {newConfig: {dataId}});const nextLayer = stateWithDataId.layers.find(l => l.id === oldLayer.id);- return nextLayer- ? layerConfigChangeUpdater(state, {oldLayer: nextLayer, newConfig: restConfig})+ return nextLayer && Object.keys(restConfig).length+ ? layerConfigChangeUpdater(stateWithDataId, {oldLayer: nextLayer, newConfig: restConfig}): stateWithDataId;}diff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.jsindex ff90117a7..6f5b2f505 100644--- a/test/node/reducers/vis-state-test.js+++ b/test/node/reducers/vis-state-test.js@@ -49,7 +49,8 @@ import {geoJsonTripFilterProps,expectedDataToFeature,updatedGeoJsonLayer,- fields as geojsonFields+ fields as geojsonFields,+ rows as geojsonRows} from 'test/fixtures/geojson';import tripGeojson, {timeStampDomain, tripDataInfo} from 'test/fixtures/trip-geojson';@@ -628,6 +629,40 @@ test('visStateReducer -> layerDataIdChangeUpdater', t => {t.end();});+test('visStateReducer -> layerDataIdChangeUpdater -> geojson', t => {+ const initialState = CloneDeep(StateWFilesFiltersLayerColor).visState;+ const nextState = reducer(+ initialState,+ // add another geojson+ VisStateActions.updateVisData([+ {+ info: {id: 'geojson2', label: 'Some Geojson'},+ data: {fields: geojsonFields, rows: geojsonRows.slice(0, 3)}+ }+ ])+ );++ // find geojson layer+ const index = nextState.layers.findIndex(l => l.type === 'geojson');+ const geojsonLayer = nextState.layers[index];+ const id = geojsonLayer.id;+ // change dataId+ const nextState1 = reducer(+ nextState,+ VisStateActions.layerConfigChange(geojsonLayer, {+ dataId: 'geojson2'+ })+ );++ const neextGeojsonLayer = nextState1.layers.find(l => l.id === id);++ t.equal(neextGeojsonLayer.config.dataId, 'geojson2', 'should update layer dataId');+ t.equal(neextGeojsonLayer.dataToFeature.length, 3, 'should calculate dataToFeature');+ t.equal(nextState1.layerData[index].data.length, 3, 'should calculate layerData');++ t.end();+});+test('visStateReducer -> layerDataIdChangeUpdater -> validation', t => {const initialState = CloneDeep(StateWFilesFiltersLayerColor).visState;const pointLayer = initialState.layers[0];