Skip to content

fix: decode commenter names in comments widget - #507

Merged
AllTerrainDeveloper merged 2 commits into
WordPress:trunkfrom
Pranjal1423:fix/recent-comments-author-entities
Aug 6, 2026
Merged

fix: decode commenter names in comments widget#507
AllTerrainDeveloper merged 2 commits into
WordPress:trunkfrom
Pranjal1423:fix/recent-comments-author-entities

Conversation

@Pranjal1423

Copy link
Copy Markdown
Contributor

Closes #496

Description

This PR fixes a visual bug where HTML entities in commenter names (such as ampersands &) were rendered raw inside the Recent Comments widget on the desktop.

Root Causes & Fixes

Missing Entity Decoding in Commenter Name Render:

  • Issue: The REST API returns comment author names containing HTML-encoded entities in the author_name payload (e.g. Q&A Guest). The Recent Comments widget set these directly using .textContent, which caused them to render literally on the screen and broke the initials-based avatar bubble generation (grabbing & instead of the correct letter).
  • Fix: Updated the loop in src/plugins/recent-comments-widget/index.ts to decode the commenter name using the existing decodeHTML utility from src/utils.ts before setting it to the author element and generating the avatar initial.

Verification

  • Build: npm run build completed successfully.
  • Typecheck: npm run typecheck completed successfully with zero errors.
  • Linter: npm run lint completed successfully with zero errors.
  • Unit Tests: npm run test:js completed successfully with all 3789/3789 Vitest tests passing.

Before fix

Screenshot 2026-08-05 at 4 23 04 PM

After fix

Screenshot 2026-08-05 at 6 32 27 PM

@AllTerrainDeveloper AllTerrainDeveloper left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you!

@AllTerrainDeveloper
AllTerrainDeveloper merged commit 2cb62cb into WordPress:trunk Aug 6, 2026
6 checks passed
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.

Recent Comments widget renders raw HTML entities in commenter names

2 participants