Skip to content

Render mobile sticky ads only if reader revenue banner is absent#2351

Open
dskamiotis wants to merge 7 commits intomainfrom
ds/load-mobile-sticky-ads-conditionally
Open

Render mobile sticky ads only if reader revenue banner is absent#2351
dskamiotis wants to merge 7 commits intomainfrom
ds/load-mobile-sticky-ads-conditionally

Conversation

@dskamiotis
Copy link
Contributor

@dskamiotis dskamiotis commented Dec 22, 2025

What does this change?

The mobile sticky ad slot now responds to banner lifecycle events from DCR, ensuring it only displays when engagement banners are not present.

Why?

Mobile sticky ads and engagement banners compete for the same screen real estate at the bottom of the viewport. Previously, both could display simultaneously, creating a poor user experience. This change ensures the mobile sticky ad only appears when there's no banner conflict.

This prevents ads from showing up in the DOM and going against google ad policy

Related to guardian/dotcom-rendering#15053 which implements new event being emitted.

Event handling:

  • Added event listeners for banner:close and banner:none events dispatched by DCR
  • Mobile sticky ad slot now loads conditionally based on banner state
  • When a banner closes, the mobile sticky ad is inserted into the page
  • When no banner is present (banner:none), the ad loads immediately

Testing:

  • Added Playwright E2E tests to verify banner/ad interaction flow
  • Test user journey: banner display → banner dismissal → ad appearance
  • Test event-driven behavior: banner:none triggers ad loading
  • Removed manual event dispatch in favor of realistic UI interactions (button clicks)

Testing done

  • ✅ Playwright tests pass for mobile viewport
  • ✅ Verified banner shows first, blocking mobile sticky ad
  • ✅ Verified mobile sticky ad appears after banner dismissal
  • ✅ Verified banner:none event triggers ad loading when no banner present

@changeset-bot
Copy link

changeset-bot bot commented Dec 22, 2025

⚠️ No Changeset found

Latest commit: 7891d65

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dskamiotis dskamiotis force-pushed the ds/load-mobile-sticky-ads-conditionally branch from 785cc3f to d54a028 Compare December 22, 2025 10:01
@github-actions
Copy link
Contributor

github-actions bot commented Dec 22, 2025

Size Change: +94 B (+0.04%)

Total Size: 225 kB

Filename Size Change
bundle/dist/prod/artifacts/commercial/********************/graun.consented-advertising.commercial.js 28.6 kB +91 B (+0.32%)
ℹ️ View Unchanged
Filename Size Change
bundle/dist/prod/artifacts/commercial/********************/graun.consentless-advertising.commercial.js 1.8 kB 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.966.commercial.js 14.4 kB 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.588.commercial.js 125 kB 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.155.commercial.js 7.44 kB 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.366.commercial.js 13.5 kB 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.899.commercial.js 3.46 kB 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.standalone.commercial.js 18.8 kB +2 B (+0.01%)
bundle/dist/prod/artifacts/commercial/********************/graun.ad-free.commercial.js 4.61 kB +1 B (+0.02%)
bundle/dist/prod/artifacts/commercial/********************/graun.Prebid.js.commercial.js 2.5 kB 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.540.commercial.js 615 B 0 B
bundle/dist/prod/artifacts/commercial/********************/graun.299.commercial.js 4.36 kB 0 B

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 22, 2025

@dskamiotis dskamiotis changed the title Load mobile sticky ads only when the reader revenue banner is not pre… Render mobile sticky ads only if reader revenue banner is absent Dec 22, 2025
@dskamiotis dskamiotis added health feature Departmental tracking: work on a new feature and removed health labels Dec 22, 2025
@dskamiotis dskamiotis force-pushed the ds/load-mobile-sticky-ads-conditionally branch from 201e6b4 to 1422c34 Compare January 8, 2026 11:39
@dskamiotis dskamiotis marked this pull request as ready for review January 8, 2026 11:40
@dskamiotis dskamiotis requested a review from a team as a code owner January 8, 2026 11:40
Copy link
Contributor

@cemms1 cemms1 left a comment

Choose a reason for hiding this comment

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

Looking great and really neat! Nice one adding a Playwright test too!


// Dismiss banner
await page.getByRole('button', { name: 'Collapse banner' }).click();
await page.getByText('Maybe later').click();
Copy link
Contributor

Choose a reason for hiding this comment

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

This text could change so is a bit fragile, but we don't have anything better here due to the way it appears in the DOM! If we find this test fails due to text changes, we should try to establish a more concrete identifier for this button (and the previous "Collapse banner" one)

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

Labels

Do not merge feature Departmental tracking: work on a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants