Skip to content

fix(audience): decode HTML entities in campaign prompt titles#4711

Open
adekbadek wants to merge 2 commits into
trunkfrom
fix/campaigns-conflict-prompt-title-entities
Open

fix(audience): decode HTML entities in campaign prompt titles#4711
adekbadek wants to merge 2 commits into
trunkfrom
fix/campaigns-conflict-prompt-title-entities

Conversation

@adekbadek
Copy link
Copy Markdown
Member

@adekbadek adekbadek commented May 11, 2026

All Submissions:

Changes proposed in this Pull Request:

Prompt titles come back from the REST API HTML-encoded (a prompt named Foo & Bar arrives as Foo & Bar). The Campaigns wizard rendered the raw title string in two places, so the entity showed through literally:

  1. The "Conflict detected" notice shown when two prompts target the same placement + segment – it listed the conflicting prompt's title verbatim.
  2. The prompt preview modal title (Prompt: …).

Both now run the title through decodeEntities from @wordpress/html-entities, matching how prompt titles are already displayed elsewhere (e.g. prompt-action-card).

Before / After (conflict notice)

Rendered text
Before Spring Membership Drive & Renewal: If multiple overlays are rendered…
After Spring Membership Drive & Renewal: If multiple overlays are rendered…

How to test the changes in this Pull Request:

  1. Have Newspack Campaigns set up with at least two published overlay (or above-header / custom-placement) prompts assigned to the same segment, where one prompt's title contains an & that WordPress stored as &amp; (e.g. set it directly: wp db query "UPDATE wp_posts SET post_title='Donate &amp; Subscribe' WHERE ID=<prompt_id>").
  2. Open Audience → Campaigns. Find the segment group with the conflicting prompts.
  3. The "Conflict detected" notice should list the other prompt's title with a literal &, not &amp;.
  4. Also click Preview on a prompt whose title contains an entity – the modal heading should read Prompt: Donate & Subscribe, not Prompt: Donate &amp; Subscribe.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable? (SegmentGroup.test.js – "decodes HTML entities in conflicting prompt titles"; red/green verified)
  • Have you successfully ran tests with your changes locally? (SegmentGroup.test.js suite passes; wp-scripts lint-js clean on changed files)

🤖 Generated with Claude Code

Prompt titles arrive from the REST API HTML-encoded (e.g. "Foo &amp; Bar"),
so the Campaigns wizard rendered the raw entity in two spots: the
"Conflict detected" notice and the preview modal title. Run both through
decodeEntities, matching how prompt titles are shown elsewhere.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes HTML-encoded prompt titles (e.g. &amp;) showing up literally in the Audience → Campaigns UI by decoding entities before rendering, aligning these surfaces with other components that already decode prompt titles.

Changes:

  • Decode HTML entities for conflicting prompt titles shown in the “Conflict detected” notice.
  • Decode HTML entities for the prompt preview modal title (Prompt: …).
  • Add a unit test to verify entity decoding in conflict notice titles.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/wizards/audience/views/campaigns/utils.js Decodes entities when rendering conflicting prompt titles in the conflict warning UI.
src/wizards/audience/views/campaigns/index.js Decodes entities in the preview modal title before interpolating into Prompt: %s.
src/wizards/audience/components/segment-group/SegmentGroup.test.js Adds coverage ensuring conflicting prompt titles are decoded in rendered notices.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/wizards/audience/views/campaigns/utils.js Outdated
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@adekbadek adekbadek marked this pull request as ready for review May 11, 2026 09:20
@adekbadek adekbadek requested a review from a team as a code owner May 11, 2026 09:20
@adekbadek adekbadek added the [Status] Needs Review The issue or pull request needs to be reviewed label May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Needs Review The issue or pull request needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants