Skip to content

Conversation

j-ruda-guardian
Copy link

@j-ruda-guardian j-ruda-guardian commented Aug 22, 2025

What does this change?

Implements the visible reCAPTCHA on the All Newsletters page.

  • Controlled via the new feature switch (ManyNewsletterVisibleRecaptcha).
  • The switch will remain off for now — reCAPTCHA will be launched in a future PR with AB testing.

Adds an opt-in checkbox for “similar Guardian products”:

  • The checkbox is only visible for logged-out users.
  • When logged in:
    -- Checkbox is not displayed.
    -- No marketing param is sent to the backend.
    -- Existing subscription status remains unaffected.
  • When logged out:
    -- Checkbox is displayed.
    -- The marketing param is sent to the backend with the correct value (true/false) depending on opt-in choice.

Why?

  • To prepare for the upcoming launch of visible reCAPTCHA with AB testing.
  • To provide logged-out users with an explicit opt-in/out choice for similar Guardian products, aligning with product/legal requirements.
  • To ensure logged-in users’ preferences are not disrupted by redundant and conflicting marketing signals.

Screenshots

Before After
before1 after1
before2 after2
before3 after3

Product note: Product decided not to AB test the checkbox itself. The AB test will apply only to the visible reCAPTCHA, which will be launched in the next PR

@j-ruda-guardian j-ruda-guardian requested a review from a team as a code owner August 22, 2025 14:39
Copy link

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

Copy link

github-actions bot commented Aug 22, 2025

Copy link

github-actions bot commented Aug 22, 2025

@j-ruda-guardian j-ruda-guardian added the run_chromatic Runs chromatic when label is applied label Aug 26, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Aug 26, 2025
Copy link
Contributor

@DanielCliftonGuardian DanielCliftonGuardian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Just a suggestion that could improve the readability of the ManyNewslettersForm

Comment on lines 203 to 271
<div css={inputAndOptInWrapperStyle}>
<span css={inputWrapperStyle}>
<TextInput
label="Enter your email"
value={email}
onChange={handleTextInput}
error={errorMessage}
disabled={status === 'Loading'}
onFocus={() =>
setFirstInteractionOccurred(true)
}
/>
</span>
{isMarketingOptInVisible && (
<div>
<CheckboxGroup
name="marketing-preferences"
label="Marketing preferences"
hideLabel={true}
cssOverrides={optInCheckboxTextSmall}
>
<Checkbox
label="Get updates about our journalism and ways to support and enjoy our work."
value="marketing-opt-in"
checked={marketingOptIn}
onChange={(e) =>
setMarketingOptIn(
e.target.checked,
)
}
theme={{
fillUnselected:
palette.neutral[100],
borderUnselected:
palette.neutral[46],
fillSelected:
palette.brand[500],
borderSelected:
palette.brand[500],
borderHover: palette.brand[500],
}}
/>
</CheckboxGroup>
</div>
)}
{useReCaptcha && !!captchaSiteKey && (
<div
css={css`
.grecaptcha-badge {
visibility: hidden;
}
`}
>
{(!visibleRecaptcha ||
firstInteractionOccurred) && (
<ReactGoogleRecaptcha
sitekey={captchaSiteKey}
ref={reCaptchaRef}
onError={handleCaptchaError}
size={
visibleRecaptcha
? 'normal'
: 'invisible'
}
/>
)}
</div>
)}
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of conditional logic in this component we could improve readability by creating a FormFields component and isolate the logic for handling the form inputs, the opt-in and the recaptcha

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the review and the nice suggestion! I've implemented this change now

e.target.checked,
)
}
theme={{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you only need to set fillUnselected here? (Which has a default value of transparent.) The other properties are the same as the default values so aren't needed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, thank you for catching this! I've implemented this change now

@j-ruda-guardian j-ruda-guardian added the run_chromatic Runs chromatic when label is applied label Aug 28, 2025
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Aug 28, 2025

const optInCheckboxTextSmall = css`
label > div {
font-size: 13px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has a designer specified the font size to use here? 13px is a non-standard size so it may be better to use one of the typography presets, perhaps textSans14?

https://guardian.github.io/storybooks/?path=/docs/source_foundations-typography--docs

Overriding the label's font size also affects the alignment with the checkbox so you may need to adjust the margin to keep the first line of the label aligned with the centre of the checkbox.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching this! I updated the size to use 14 which is what is defined in the designs.

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

Successfully merging this pull request may close these issues.

3 participants