From f189ae603ef266c4a0b341c4683dc2fde080eb73 Mon Sep 17 00:00:00 2001 From: Maciej Ziarkowski Date: Wed, 16 Oct 2019 13:11:25 +0100 Subject: [PATCH] Clear all state fields on select change --- app/src/frontend/building/data-container.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/frontend/building/data-container.tsx b/app/src/frontend/building/data-container.tsx index f3955f36..593c7112 100644 --- a/app/src/frontend/building/data-container.tsx +++ b/app/src/frontend/building/data-container.tsx @@ -81,10 +81,14 @@ const withCopyEdit = (WrappedComponent) => { } static getDerivedStateFromProps(props, state) { - if(props.building != undefined && props.building.building_id !== state.currentBuildingId) { + const newBuildingId = props.building == undefined ? undefined : props.building.building_id; + if(newBuildingId !== state.currentBuildingId) { return { + error: undefined, + copying: false, + keys_to_copy: {}, buildingEdits: {}, - currentBuildingId: props.building.building_id + currentBuildingId: newBuildingId }; }