Skip to content

Commit

Permalink
fix: Negative probability slider [PT-187357469]
Browse files Browse the repository at this point in the history
This ensures that no probability values can go below zero.
  • Loading branch information
dougmartin committed Apr 6, 2024
1 parent 43222f5 commit e9f824d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/drawing/probability-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ export const ProbabilitySelector = ({exactPercentages, edgeLabels, onChange}: Pr
newExactPercentages[index] = newExactPercentage;
newExactPercentages[index+1] = pairedPercentageSum - newExactPercentage;

onChange(newExactPercentages);
const allAboveZero = newExactPercentages.find(n => n < 0) === undefined;
if (allAboveZero) {
onChange(newExactPercentages);
}
}, [exactPercentages, onChange]);

if (exactPercentages.length < 2) {
Expand Down

0 comments on commit e9f824d

Please sign in to comment.