Skip to content

Commit

Permalink
fix: FormulaWidgetUI render when data is zero
Browse files Browse the repository at this point in the history
When data was 0, a render was not happening, leaving the widget with the previous value, causing a bug
  • Loading branch information
VictorVelarde committed Mar 21, 2021
1 parent ae96f11 commit a60efbc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/react-ui/src/widgets/utils/animations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit a60efbc

Please sign in to comment.