Skip to content

fix(voters): stop showing "Invalid Voter ID" before the voter types anything - #1572

Open
masiarek wants to merge 1 commit into
Equal-Vote:mainfrom
masiarek:fix/voter-id-required-string
Open

masiarek wants to merge 1 commit into
Equal-Vote:mainfrom
masiarek:fix/voter-id-required-string

Conversation

@masiarek

Copy link
Copy Markdown
Collaborator

Description

In an ID-list election, the voter-ID field renders in its error state with "Invalid Voter ID" from the moment the page loads — before the voter has typed a character.

Cause: VoterAuth.tsx:47 tests voterAuth?.required === "Voter ID Required", but the backend (voterRollUtils.ts getMissingAuthData) returns "Voter ID Required for closed elections". The comparison never matches, so missingVoterID is always false, and the error branch (!missingVoterID && !isAuthorized) is true on first paint.

Fix: compare against the string the backend actually sends. One line, frontend side — the backend string may appear in logs, so the compare is the safer end to change. The sibling check ("Email Validation Required") already matches its backend string exactly, which is how this drifted unnoticed: one of the two worked.

After the fix the field starts neutral, and the error appears only after a submitted ID actually fails.

Longer-term these magic-string comparisons would be safer as shared constants or an enum on the auth response — happy to do that as a follow-up if wanted; this PR is the minimal behaviour fix.

Screenshots / Videos (frontend only)

Behaviour fix visible in any ID-list election: before, the field is red with "Invalid Voter ID" on load; after, it is neutral until a wrong ID is submitted.

Related Issues

Found while writing the voter troubleshooting help page (#1550, indexed in #1556).

…nything

In an ID-list election the voter-ID field renders in its error state with the
helper text "Invalid Voter ID" from the moment the page loads, before the voter
has typed a character. First impression of the voting flow: you got it wrong.

Cause: VoterAuth.tsx tests voterAuth?.required === "Voter ID Required", but the
backend (voterRollUtils.ts getMissingAuthData) returns "Voter ID Required for
closed elections". The comparison never matches, so missingVoterID is always
false and the error branch (!missingVoterID && !isAuthorized) is true on first
paint.

Fixed on the frontend side by comparing against the string the backend actually
sends. The sibling check ("Email Validation Required") already matches its
backend string exactly, which is how the drift went unnoticed -- one of the two
worked.

With the comparison fixed, the field starts in its neutral state and the error
appears only after a submitted ID actually fails.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@netlify

netlify Bot commented Aug 19, 2026

Copy link
Copy Markdown

Deploy Preview for bettervoting ready!

Name Link
🔨 Latest commit 6295c4d
🔍 Latest deploy log https://app.netlify.com/projects/bettervoting/deploys/6a861811c6346e000800727e
😎 Deploy Preview https://deploy-preview-1572--bettervoting.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b17c65b3-7ced-4675-8eb0-977defd9813a

📥 Commits

Reviewing files that changed from the base of the PR and between 454a38a and 6295c4d.

📒 Files selected for processing (1)
  • packages/frontend/src/components/Election/VoterAuth.tsx

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Updated voter ID validation messaging for closed elections.
    • Ensured the correct “Voter ID Required for closed elections” message is recognized.

Walkthrough

The voter authentication check now identifies the message "Voter ID Required for closed elections" when determining whether a voter ID is missing.

Poem

I’m a rabbit with a watchful eye,
Checking voter messages as they fly.
Closed elections now speak clear,
“Voter ID Required” appears here.
One small change, the check hops bright! 🐇

Merge Risk: ⚪ Minimal · up to 6295c

This localized frontend fix changes the voter-ID field from an incorrect error state on initial load to the intended neutral state until an invalid ID is submitted. No actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary voter ID behavior fix.
Description check ✅ Passed The description explains the cause, fix, expected behavior, and related issues; screenshots are described but not provided.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant