Skip to content

Make Playlist waveform seeking keyboard accessible#78980

Open
scruffian wants to merge 9 commits into
trunkfrom
scruffian/waveform-a11y-seek
Open

Make Playlist waveform seeking keyboard accessible#78980
scruffian wants to merge 9 commits into
trunkfrom
scruffian/waveform-a11y-seek

Conversation

@scruffian
Copy link
Copy Markdown
Contributor

@scruffian scruffian commented Jun 5, 2026

What?

Makes the Playlist block waveform seek control keyboard-operable and exposes it as an accessible slider.

Why?

Keyboard-only users could reach the play button but could not focus or operate the waveform seek control without a mouse click.

How?

Adds wrapper-level slider semantics, ARIA value syncing, keyboard seek handling, focus styling, editor/frontend label updates, and unit/e2e coverage without patching @arraypress/waveform-player.

Testing Instructions

  1. Create or open a post with a Playlist block containing an audio track.
  2. View the post on the frontend.
  3. Confirm the waveform has a visible focus outline and its accessible slider value updates while seeking.

Testing Instructions for Keyboard

  1. On the frontend, use Tab to move focus to the Playlist waveform after the play button.
  2. Press ArrowRight and confirm playback position advances by 5 seconds.
  3. Press ArrowLeft, ArrowUp, ArrowDown, PageUp, PageDown, Home, and End and confirm the slider seek position changes as expected.

Screenshots or screencast

N/A

Use of AI Tools

Implemented with assistance from OpenAI Codex; the generated changes were reviewed before publishing.

Validation

Ran node --check on touched non-JSX JavaScript files and git diff --check.
npm run test:unit packages/block-library/src/utils/test/waveform-utils.js could not run because node_modules was missing, and npm install failed with ENOSPC: no space left on device.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

Size Change: +2.73 kB (+0.03%)

Total Size: 8.21 MB

📦 View Changed
Filename Size Change
build/modules/block-library/playlist/view.min.js 11.7 kB +784 B (+7.17%) 🔍
build/scripts/block-library/index.min.js 324 kB +597 B (+0.18%)
build/styles/block-library/playlist/style-rtl.css 1.7 kB +165 B (+10.78%) ⚠️
build/styles/block-library/playlist/style-rtl.min.css 1.6 kB +164 B (+11.4%) ⚠️
build/styles/block-library/playlist/style.css 1.7 kB +165 B (+10.75%) ⚠️
build/styles/block-library/playlist/style.min.css 1.61 kB +164 B (+11.37%) ⚠️
build/styles/block-library/style-rtl.css 21.8 kB +166 B (+0.77%)
build/styles/block-library/style-rtl.min.css 18.4 kB +181 B (+1%)
build/styles/block-library/style.css 21.9 kB +166 B (+0.76%)
build/styles/block-library/style.min.css 18.3 kB +176 B (+0.97%)

compressed-size-action

Mirror the editor by setting the seek slider's accessible name to the
track title after creating the player on the frontend, so the slider is
discoverable by title instead of the generic "Seek" label.

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

github-actions Bot commented Jun 5, 2026

Flaky tests detected in 89a395a.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/27019490592
📝 Reported issues:

@scruffian scruffian marked this pull request as ready for review June 5, 2026 13:29
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: scruffian <scruffian@git.wordpress.org>
Co-authored-by: jeryj <jeryj@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

scruffian and others added 2 commits June 5, 2026 14:35
- Add updateSeekControlLabel to the jest mock of waveform-utils so the
  WaveformPlayer component tests stop throwing "not a function".
- Use window.KeyboardEvent in the seek-control tests (no-undef).
- Collapse a multi-line toHaveAttribute call (prettier).
- Align the setupSeekControlAccessibility JSDoc params (jsdoc).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mark setupSeekControlAccessibility as a deliberate stopgap over
@arraypress/waveform-player and link the upstream accessibility issue
so the coupling to library internals can be removed once fixed there.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@scruffian scruffian added the [Type] Bug An existing feature does not function as intended label Jun 5, 2026
@scruffian scruffian self-assigned this Jun 5, 2026
@scruffian scruffian added [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Block] Playlist labels Jun 5, 2026
@scruffian scruffian requested a review from Copilot June 5, 2026 13:48
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 makes the Playlist block’s waveform seek control keyboard-operable and exposes it as an accessible slider, improving frontend usability for keyboard-only and assistive-technology users without requiring upstream changes to @arraypress/waveform-player.

Changes:

  • Adds a seek-control accessibility shim (ARIA slider semantics, value syncing, and keyboard seeking) to the shared waveform utilities.
  • Syncs/updates the seek control’s accessible label in both the editor React component and the frontend Interactivity implementation.
  • Adds focus-visible styling plus unit and e2e coverage for the new accessibility behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/e2e/specs/editor/blocks/playlist.spec.js Adds an e2e check that the waveform seek control is reachable and operable via keyboard on the frontend.
packages/block-library/src/utils/waveform-utils.js Introduces seek-control slider semantics, ARIA value syncing, and keyboard seek handling (plus label update helper).
packages/block-library/src/utils/waveform-player.js Wires translated seek label into the editor player and updates the slider label when metadata changes.
packages/block-library/src/utils/test/waveform-utils.js Adds unit tests for seek control accessibility setup and label updates.
packages/block-library/src/utils/test/waveform-player.js Extends mocks to include the new seek label updater used by the editor component.
packages/block-library/src/playlist/view.js Updates frontend player initialization/track switching to sync the seek control label.
packages/block-library/src/playlist/style.scss Adds focus-visible outline styling for the waveform seek control.
packages/block-library/src/playlist/index.php Adds a translated data-label-seek attribute for frontend initialization.

Comment thread test/e2e/specs/editor/blocks/playlist.spec.js Outdated
Comment thread packages/block-library/src/utils/waveform-utils.js
Comment thread packages/block-library/src/utils/waveform-player.js Outdated
scruffian and others added 2 commits June 5, 2026 14:55
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Pass a localized fallback to updateSeekControlLabel instead of the
  hard-coded "Seek" when a track has no title (editor uses __('Seek'),
  frontend uses the server-rendered data-label-seek).
- Round rather than floor in formatTimestamp so fractional media
  durations (e.g. 11.999s) aren't announced one second short.
- Use a per-process unique temp filename in the e2e fixture to avoid
  collisions between parallel Playwright workers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jeryj and others added 2 commits June 5, 2026 14:18
The "instead of volume changes" test asserted setVolume was never
called, but nothing in the shim ever calls setVolume and the library
isn't instantiated in the unit test, so the assertion could never fail.
The library's volume keybindings are also inert in our setup: focus
lives on the inner seek control while the library guards its handler on
its own (outer) container being focused.

Repurpose the test to assert the behavior we actually rely on -
vertical arrows map to seeking (ArrowUp/ArrowDown).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@scruffian
Copy link
Copy Markdown
Contributor Author

@copilot can you do another review please?

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 5, 2026

@copilot can you do another review please?

I re-reviewed the PR changes and didn’t find any new material issues (bugs, regressions, security, or accessibility blockers). I also checked recent branch workflow runs and there are no completed failures to address right now, so no additional code changes were needed in this pass.

Keyboard users were landing on the library's outer player wrapper rather
than the accessible slider, and there was no visible affordance showing
where a seek would land.

- Redirect focus from the player wrapper onto the role="slider" element
  so keyboard navigation operates the seek control directly.
- Add a keyboard playhead bar with a timestamp tooltip, shown on focus,
  which doubles as the focus indicator (replacing the box outline).
- Add a hover preview that darkens the targeted spot and shows its
  timestamp.
- Drive overlay visibility from CSS (:focus-visible / is-seek-hovering)
  and only position them from JS; tear them down in cleanup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Playlist [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Block library /packages/block-library [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants