Skip to content

Newsletter Signup Form - signed in and out#15747

Open
georgerichmond wants to merge 4 commits intomainfrom
newsletter-signup-form-signed-in-and-out
Open

Newsletter Signup Form - signed in and out#15747
georgerichmond wants to merge 4 commits intomainfrom
newsletter-signup-form-signed-in-and-out

Conversation

@georgerichmond
Copy link
Copy Markdown
Contributor

@georgerichmond georgerichmond commented Apr 24, 2026

What does this change?

Implements the signed-in and signed-out flows for the new NewsletterSignupForm component, closing issues #15678 and #15686.

New components & files

  • NewsletterSignupForm.island.tsx — the new auth-aware signup form, replacing SecureSignup as the inner content of the newsletter signup card when showNewNewsletterSignupCard is enabled. Supports both signed-in (email pre-filled from Identity, email input hidden) and signed-out (email input visible) states in a single component.
  • useNewsletterSignupForm.ts — a custom hook that encapsulates all form state and side-effects (email resolution, reCAPTCHA, Ophan tracking, form submission). Extracted from the component so that every visual state is trivially reproducible in Storybook by mocking a single hook, and to keep the component itself as a pure rendering layer.

Signed-in flow (closes #15678)

  • Email is pre-filled from Identity; the email <input> is hidden
  • "Sign up" button is shown; on success, displays "You're signed up!", the newsletter name & frequency, and a "Browse more newsletters" link
  • Privacy message is rendered outside the card (below it), since the marketing toggle is not shown for signed-in users
  • Ophan tracking reuses the same interaction lifecycle as SecureSignup

Signed-out flow (closes #15686)

  • Email input with "Enter your email" label and a "Sign up" button
  • Marketing opt-in toggle and privacy message are revealed when the email field is focused/interacted with
  • Inline validation error shown for empty or incorrectly formatted email
  • Same success state as the signed-in flow after submission completes
  • Ophan tracking reuses the same interaction lifecycle as SecureSignup

Why a custom hook?

All form logic (email fetch, reCAPTCHA, marketing opt-in, Ophan tracking, submission, validation) lives in useNewsletterSignupForm. This separation means:

  1. Storybook screenshots are easy — every visual state (idle, focused, loading, success, failure, validation error) can be covered by mocking the single hook return value, with no need to stub network requests or drive interactions.
  2. The component stays thinNewsletterSignupFormActive is purely a rendering layer, making it straightforward to review and maintain.

Refactored from SecureSignup

The submission and tracking logic (buildFormData, postFormData, sendTracking) has been lifted from SecureSignup.island.tsx and consolidated into useNewsletterSignupForm. SecureSignup was previously used as an intermediate placeholder inside the new card; it is now replaced by NewsletterSignupForm.

Other changes

  • NewsletterSignupCardContainer updated to accept a render-prop children (so it can pass openPreview down), and now renders the privacy message outside the card when the user is signed in
  • EmailSignUpWrapper wired up to pass isSignedIn and the new form props through to NewsletterSignupCardContainer
  • renderElement.tsx prop name corrected (showNewsletterSignupCardshowNewNewsletterSignupCard)
  • Minor NewsletterSignupCard style tweaks (illustration size, spacing)

Why?

Part of the rollout of the new newsletter signup card design. This PR delivers the complete signup experience for both signed-in and signed-out readers.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 24, 2026

@georgerichmond georgerichmond force-pushed the newsletter-signup-form-signed-in-and-out branch from 12262f4 to ac85def Compare April 24, 2026 08:32
@georgerichmond georgerichmond added run_chromatic Runs chromatic when label is applied feature Departmental tracking: work on a new feature labels Apr 24, 2026
@georgerichmond georgerichmond marked this pull request as ready for review April 24, 2026 08:46
@georgerichmond georgerichmond requested a review from a team as a code owner April 24, 2026 08:46
@github-actions github-actions Bot removed the run_chromatic Runs chromatic when label is applied label Apr 24, 2026
@georgerichmond georgerichmond self-assigned this Apr 24, 2026
@georgerichmond georgerichmond added the run_chromatic Runs chromatic when label is applied label Apr 24, 2026
@github-actions github-actions Bot removed the run_chromatic Runs chromatic when label is applied label Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Departmental tracking: work on a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NewsletterSignup.island.tsx - signed-out flow NewsletterSignup.island.tsx — signed in flow

1 participant