Skip to content

Commit

Permalink
fix(protocol-designer): flow rate field to auto-populate default value (
Browse files Browse the repository at this point in the history
  • Loading branch information
jerader authored Nov 5, 2024
1 parent 8040b74 commit 86f6547
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export function FlowRateField(props: FlowRateFieldProps): JSX.Element {
let errorMessage: string | null = null
if (
(!isPristine && passThruProps.value !== undefined && flowRateNum === 0) ||
outOfBounds
outOfBounds ||
(isPristine && flowRateNum === 0)
) {
errorMessage = i18n.format(
t('step_edit_form.field.flow_rate.error_out_of_bounds', {
Expand All @@ -71,10 +72,10 @@ export function FlowRateField(props: FlowRateFieldProps): JSX.Element {
}

useEffect(() => {
if (isPristine && errorMessage != null) {
if (isPristine && passThruProps.value == null) {
passThruProps.updateValue(defaultFlowRate)
}
}, [])
}, [isPristine, passThruProps])

return (
<InputStepFormField
Expand Down

0 comments on commit 86f6547

Please sign in to comment.