Skip to content

Add focused editor accessibility guardrails for FrontBlocks features - #283

Open
Castellon-ACM wants to merge 6 commits into
trunkfrom
focused-editor-a11y-guardrails
Open

Add focused editor accessibility guardrails for FrontBlocks features#283
Castellon-ACM wants to merge 6 commits into
trunkfrom
focused-editor-a11y-guardrails

Conversation

@Castellon-ACM

@Castellon-ACM Castellon-ACM commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #261.

Adds lightweight, advisory accessibility checks to the Carousel and Before/After inspector panels, backed by a shared, unit-testable utility module.

  • Shared utilities (assets/accessibility/frontblocks-a11y-utils.js, exposed as window.FrontBlocksA11y): WCAG contrast ratio calculation, non-text contrast (1.4.11) check, autoplay pause-control and timing safety (2.2.2), and missing image-label detection. Framework-free so it's testable with plain node --test, no wp.* globals required.
  • Carousel:
    • Adds a real "Pause on hover/focus" toggle (frblPauseOnHover, default true) — a genuine remediation, not just a warning. It also pauses on keyboard/assistive-tech focus, since Glide's own hoverpause option only reacts to mouse hover.
    • Surfaces three advisory (non-blocking) warnings in the inspector: autoplay enabled without a pause control, autoplay interval under the 5-second safety minimum, and button/background color combinations below the 3:1 non-text contrast minimum (only when both colors are set).
  • Before/After: warns when an image is set but its label is empty — since the image's <img> is always rendered with alt="", the label is the only accessible text describing what the image shows.

Requirements checklist (from the issue)

  • Advisory only — nothing here blocks publishing.
  • Only checks FrontBlocks-owned configuration (Carousel/Before-After attributes), not arbitrary content.
  • Contrast/config-rule logic lives in a shared, unit-testable utility module.
  • Warnings use @wordpress/components' Notice (accessible by design, matches this plugin's existing convention) so they're announced and keyboard-operable in the sidebar.
  • No site-wide scanner, dashboard, persisted findings, or telemetry added.

Motion-capable features beyond Carousel (Animations, Shape Animations, Text Animation) already ship prefers-reduced-motion CSS fallbacks but are intentionally left out of this PR's scope — a natural follow-up once this pattern proves useful, per the issue's own note.

Test plan

  • New JS unit tests: npm run test:accessibility-utils (17 tests, pure functions, no DOM/browser needed).
  • New PHPUnit coverage for the frblPauseOnHover attribute default and its data-pause-on-hover output (CarouselTest.php).
  • Full PHPUnit suite passes: 390 tests, 773 assertions.
  • composer lint (phpcs) clean.
  • php -l / node -c clean on all touched files.
Open WordPress Playground Preview

Framework-free, unit-testable functions for the checks needed by
issue #261: WCAG contrast ratio calculation, non-text contrast
(1.4.11), autoplay pause-control and timing safety (2.2.2), and
missing image label detection. Exposed as window.FrontBlocksA11y so
any block's InspectorControls can reuse them without a build step.
Registers frontblocks-a11y-utils globally and loads it as a
dependency of both the Carousel and Before/After block editor
scripts, so their InspectorControls can use window.FrontBlocksA11y.
The block's images are always rendered with alt="" (decorative);
the before/after label is the only accessible text describing what
each image shows. Flags it, advisory-only, when an image is set but
its label is empty or whitespace.
Adds a real "Pause on hover/focus" toggle (frblPauseOnHover, default
true) so autoplaying carousels have an actual way to be paused,
including via keyboard/assistive-tech focus (Glide's own hoverpause
only reacts to mouse hover).

Surfaces three advisory, non-blocking inspector warnings using the
shared accessibility utils:
- autoplay enabled with no pause control (WCAG 2.2.2)
- autoplay interval under the 5-second safety minimum
- button color vs. background color below the 3:1 non-text contrast
  minimum (WCAG 1.4.11), only when both colors are set
Covers the frblPauseOnHover default (true) in both attribute
registration filters, and its data-pause-on-hover output in the
grid block content filter, including when explicitly disabled.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

The JavaScript tests job only ran test:cookie-notice, so the new
accessibility-utils test suite added in this branch wasn't actually
enforced by CI.
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.

Add focused editor accessibility guardrails for FrontBlocks features

1 participant