diff --git a/src/vote/ScoreItem.tsx b/src/vote/ScoreItem.tsx index a0df6b02..7dc62a69 100644 --- a/src/vote/ScoreItem.tsx +++ b/src/vote/ScoreItem.tsx @@ -1,5 +1,5 @@ import { range } from 'lodash-es' -import { Dispatch } from 'react' +import { Dispatch, useEffect } from 'react' import { default_max_score, default_min_score } from 'src/admin/BallotDesign/Wizard' import { Label, TitleDescriptionQuestion } from './Item' @@ -25,6 +25,21 @@ export const ScoreItem = ({ const scoreOptions = range(min_score, max_score + 1) + // On first load, set all scores to 'BLANK' + useEffect(() => { + const update: Record = {} + options.forEach(({ name, value }) => { + const val = value || name + const key = `${id}_${val}` + + // Stop if we already have a stored value + if (state.plaintext[key]) return + + update[key] = `BLANK` + }) + dispatch(update) + }, []) + return ( <>