Skip to content

Restore the publicly-searchable toggle on the election settings page - #1490

Open
jacksonloper wants to merge 1 commit into
mainfrom
JacksonLoper/restore-is-public-toggle
Open

Restore the publicly-searchable toggle on the election settings page#1490
jacksonloper wants to merge 1 commit into
mainfrom
JacksonLoper/restore-is-public-toggle

Conversation

@jacksonloper

Copy link
Copy Markdown
Collaborator

What happened

The "Make {{election}} Publicly Searchable" (is_public) setting silently disappeared from the admin settings page. Two branches collided:

  • 4b4aec34 (Apr 28) — "fix make election publically searchable toggle". The checkbox had been writing to election.settings.is_public, but the field actually lives at the top level of Election. That commit added separate editedIsPublic state wired to election.is_public.
  • 5808a623 (authored Mar 31, merged later) — the checkbox→SwitchSetting refactor. It converted random_candidate_order, ballot_updates, require_instruction_confirmation, draggable_ballot, and max_rankings into switches, but <CheckboxSetting setting='is_public'/> was deleted and never carried over.

Because the refactor branch was authored before the fix but landed on top of it, both the fix and the setting went away in one merge. Nothing in that diff suggests it was intentional — the other four toggles all survived.

Impact

Everything below the UI still worked:

  • packages/shared/src/domain_model/Election.ts:27is_public?: boolean, still validated at :148
  • packages/backend/src/Models/Elections.ts:103getOpenElections still filters .where("is_public", "=", true)
  • packages/frontend/src/i18n/en.yaml — the label and tip text were still there, orphaned

…but the only remaining writer in the frontend was Wizard.tsx:33 hardcoding is_public: false. So no election created since that merge could ever appear on /browse — the browse tab has only been showing elections whose flag was set before the regression.

The change

Restored the setting on /admin/settings, next to the other toggles.

It uses a bare SwitchSetting + useOptimisticToggle rather than the ElectionSwitchSetting helper, because that helper writes into election.settings[key] and is_public is a top-level column — same reason the public_results switch is hand-rolled.

One addition beyond a straight revert: the switch is disabled with an explanation on voter-list elections. getOpenElections also filters on settings.voter_access == 'open', so on a closed election turning is_public on would have no visible effect. New string disabled_msgs.is_public_when_voter_list.

Verification

  • tsc --noEmit on the frontend: clean
  • eslint on the changed component: clean
  • en.yaml parses

Not covered: there's no existing E2E coverage of the settings page (testing/tests/ has no /admin/settings spec), and adding one needs the full docker stack to run against, so I didn't add a regression test here. Worth a follow-up — a switch-level assertion on that page would have caught this.

Related loose end (not fixed here)

en.yaml:923 public_description"{{capital_election}} will be open to anyone via the 'Browse Polls' page" — is now unreferenced anywhere in the frontend. It was attached to the wizard's old "public" voter-access preset, which the auth-modes refactor (7d43150b) removed. Worth deciding whether the creation wizard should offer public listing up front, rather than only via settings after the fact.

🤖 Generated with Claude Code

The is_public checkbox was dropped in 5808a62, which converted the
settings page from checkboxes to switches but didn't carry this one
over. That branch was authored before 4b4aec3 (which had just fixed
the checkbox to write election.is_public instead of the nonexistent
election.settings.is_public) and landed on top of it, so both the fix
and the setting disappeared in one merge.

Everything below the UI still worked: is_public is still a column,
electionValidation still checks it, getOpenElections still filters on
it, and the label/tip strings were still in en.yaml. But the only
remaining writer was Wizard.tsx hardcoding false, so no election
created since that merge could ever appear on /browse.

Restored as a SwitchSetting rather than an ElectionSwitchSetting since
is_public sits on the election, not in election.settings. It's disabled
with an explanation on voter-list elections, where getOpenElections'
voter_access == 'open' filter would suppress the listing anyway.

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

netlify Bot commented Aug 7, 2026

Copy link
Copy Markdown

Deploy Preview for bettervoting ready!

Name Link
🔨 Latest commit e9acc4b
🔍 Latest deploy log https://app.netlify.com/projects/bettervoting/deploys/6a7635e52f60db00076fe60e
😎 Deploy Preview https://deploy-preview-1490--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 7, 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: 8a945d1e-bae9-4536-8604-b379c013945d

📥 Commits

Reviewing files that changed from the base of the PR and between 7bc75a8 and e9acc4b.

📒 Files selected for processing (2)
  • packages/frontend/src/components/Election/Admin/ElectionSettings.tsx
  • packages/frontend/src/i18n/en.yaml

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a visibility setting for elections, allowing eligible draft elections to be marked as public.
    • Public visibility is available only when open voter access is enabled.
  • Bug Fixes

    • Prevented public visibility changes for non-draft elections or elections restricted to voter lists.
    • Added a clear message explaining why the setting may be disabled.

Walkthrough

Election settings now manage the top-level election.is_public field with optimistic state and updateElection. The public access switch is enabled only for draft elections with open voter access. Restricted elections show a localized disabled message. English localization now includes the message for elections that use a voter list.

Poem

I am a rabbit with settings to share,
A public switch hops into place with care.
Open voter access lets it glow,
Draft elections may change the show.
A voter list brings a gentle “no”—
Link access is the way to go.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: restoring the publicly searchable election toggle.
Description check ✅ Passed The description clearly explains the regression, implementation, impact, verification, and testing limitations.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch JacksonLoper/restore-is-public-toggle

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