From a60efbc32f41ba6a890ec6468e0730dd8d558d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Velarde?= Date: Sun, 21 Mar 2021 22:04:14 +0100 Subject: [PATCH] fix: FormulaWidgetUI render when data is zero When data was 0, a render was not happening, leaving the widget with the previous value, causing a bug --- packages/react-ui/src/widgets/utils/animations.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/react-ui/src/widgets/utils/animations.js b/packages/react-ui/src/widgets/utils/animations.js index 3d1dbe234..332c13bf5 100644 --- a/packages/react-ui/src/widgets/utils/animations.js +++ b/packages/react-ui/src/widgets/utils/animations.js @@ -2,7 +2,11 @@ * Animate one value from start to end, storing the current request in requestRef hook */ export function animateValue({ start, end, duration, drawFrame, requestRef }) { - if (start === end) return; + const startAndEndZero = start === 0 && end === 0; // must ensure 1 render + + if (start === end && !startAndEndZero) { + return; + } const range = end - start; let current = start; @@ -28,9 +32,7 @@ export function animateValues({ start, end, duration, drawFrame, requestRef }) { if (isEqual) return; let currentValues = end.map((elem, i) => - start[i] && start[i].name === elem.name - ? { ...elem, value: start[i].value } - : elem + start[i] && start[i].name === elem.name ? { ...elem, value: start[i].value } : elem ); let currentFrame = 0;