Skip to content

fix(advertising): stabilize placement button width, add a11y labels#4755

Open
thomasguillot wants to merge 1 commit into
trunkfrom
fix/ads-placement-button-a11y
Open

fix(advertising): stabilize placement button width, add a11y labels#4755
thomasguillot wants to merge 1 commit into
trunkfrom
fix/ads-placement-button-a11y

Conversation

@thomasguillot
Copy link
Copy Markdown
Contributor

All Submissions:

Changes proposed in this Pull Request:

Two small UX/accessibility refinements to the Ads placement cards (Advertising › Display Ads › Placements):

  • No more width jump on the Edit/Cancel toggle. Previously the button visibly resized when its label switched from "Edit" to "Cancel", causing a layout shift in the card header. The button now reserves the width of the longer label via a CSS grid stack — both labels live in the DOM, and only the inactive one is visibility: hidden. Width is derived from the actual rendered text (no magic pixel value), so the fix holds across translations.
  • Screen reader context for placement actions. "Edit", "Cancel", and "Enable" buttons repeat once per placement card, with no audible difference between them. Each button now gets an aria-label that includes the placement name — e.g. "Edit Sticky Footer", "Cancel editing Sticky Footer", "Enable Sticky Footer". The visible compact text is unchanged.

How to test the changes in this Pull Request:

  1. Go to Advertising › Display Ads › Placements (/wp-admin/admin.php?page=newspack-ads-display-ads#/placements).
  2. On any enabled placement (e.g. Global Above Header), click Edit. Verify the button text swaps to Cancel without the button width changing or surrounding header elements shifting.
  3. Click Cancel. Same check in reverse — no width jump.
  4. Open the same page with a screen reader (VoiceOver, NVDA, etc.) and tab through the action buttons. Confirm each button is announced with its placement name appended, e.g. "Edit Global Above Header, button" and "Enable Sticky Footer, button".
  5. For an enabled placement, expand it and confirm the announced label switches to "Cancel editing <placement name>".
  6. Confirm no regression on the disabled placement state — Enable button still toggles the placement on as before.

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?
  • Have you successfully ran tests with your changes locally?

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 refines the Advertising → Display Ads → Placements UI by (1) preventing layout shift when toggling the Edit/Cancel action and (2) improving screen reader clarity for repeated placement action buttons.

Changes:

  • Adds placement-specific aria-labels to Edit/Cancel and Enable buttons to provide unique, descriptive accessible names.
  • Stabilizes the Edit/Cancel button width by rendering both labels in an overlapping inline grid and toggling visibility to reserve space for the longer label.

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

@thomasguillot thomasguillot requested a review from Copilot May 26, 2026 13:29
@thomasguillot thomasguillot marked this pull request as ready for review May 26, 2026 13:31
@thomasguillot thomasguillot requested a review from a team as a code owner May 26, 2026 13:31
@thomasguillot thomasguillot added the [Status] Needs Review The issue or pull request needs to be reviewed label May 26, 2026
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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