From 68fcaef19adcaaf3dec81f675fe7e70eeac5fe8d Mon Sep 17 00:00:00 2001 From: Igor Date: Tue, 10 Dec 2019 18:18:37 -0300 Subject: [PATCH] Cleanup labelling flow --- .../src/components/Labelling/LabellingFlow.js | 39 +++++++------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/platform/viewer/src/components/Labelling/LabellingFlow.js b/platform/viewer/src/components/Labelling/LabellingFlow.js index efe54b156..d516b3173 100644 --- a/platform/viewer/src/components/Labelling/LabellingFlow.js +++ b/platform/viewer/src/components/Labelling/LabellingFlow.js @@ -44,13 +44,9 @@ const LabellingFlow = ({ const newMeasurementData = cloneDeep(measurementData); treatMeasurementData(newMeasurementData); - let newEditLocation = editLocation; - if (!editDescription && !editLocation) { - newEditLocation = true; - } setState(state => ({ ...state, - editLocation: newEditLocation, + editLocation: !editDescription && !editLocation, measurementData: newMeasurementData, })); }, [editDescription, editLocation, measurementData]); @@ -75,8 +71,8 @@ const LabellingFlow = ({ setState(state => ({ ...state, editDescription: false })); }; - const handleKeyPress = e => { - if (e.key === 'Enter') { + const handleKeyPress = event => { + if (event.key === 'Enter') { descriptionSave(); } }; @@ -120,19 +116,16 @@ const LabellingFlow = ({ * Waits for 1 sec to dismiss the labelling component. * */ - const fadeOutAndLeave = () => { - setFadeOutTimer(setTimeout(() => setShowComponent(false), 1000)); - }; + const fadeOutAndLeave = () => + setFadeOutTimer(setTimeout(fadeOutAndLeaveFast, 1000)); const fadeOutAndLeaveFast = () => setShowComponent(false); const clearFadeOutTimer = () => { - if (!fadeOutTimer) { - return; + if (fadeOutTimer) { + clearTimeout(fadeOutTimer); + setFadeOutTimer(null); } - - clearTimeout(fadeOutTimer); - setFadeOutTimer(null); }; const descriptionDialogUpdate = description => { @@ -146,15 +139,13 @@ const LabellingFlow = ({ if (!skipAddLabelButton) { return ( - <> - - + ); } else { if (editLocation) {