Expose the waveform as a keyboard-operable, ARIA slider#9
Open
scruffian wants to merge 2 commits into
Open
Conversation
The waveform seek surface was only operable by mouse: the container is tabindex="-1" until clicked, and the waveform had no role or ARIA value attributes, so keyboard-only and screen-reader users couldn't discover or operate seeking (WCAG 2.1.1, 4.1.2). Mark .waveform-container as role="slider", make it focusable, keep aria-valuemin/max/now/valuetext in sync with playback, and handle the standard slider keys (Arrow/Page/Home/End) to seek. Works in both self and external audio modes. New options: accessibleSeek (default true, opt-out) and seekLabel (accessible name, falls back to the track title). Closes arraypress#8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the waveform seek surface accessible to keyboard and assistive-technology users. Closes #8.
Today the seek area is mouse-only: the container is
tabindex="-1"until clicked, and the waveform has noroleor ARIA value attributes, so keyboard-only and screen-reader users can't discover or operate seeking (WCAG 2.1.1 Keyboard, 4.1.2 Name/Role/Value).What this does
.waveform-containerasrole="slider", focusable in the tab order (tabindex="0").aria-valuemin/aria-valuemax/aria-valuenowand a readablearia-valuetext(e.g."0:30 of 2:00") in sync on metadata load,timeupdate, and externalsetProgress().preventDefault()(no page scroll) andstopPropagation()so the existing container-level handler doesn't also fire.selfmode it callsseekTo(); inexternalmode it dispatcheswaveformplayer:request-seekwith apercent, exactly like click-to-seek.:focus-visibleoutline for the slider, matching the existing button/marker focus styling.Options
accessibleSeektruefalseto opt out and keep the prior behavior.seekLabelnull'Seek'. (Lets consumers localize the label.)Backwards compatibility
accessibleSeekdefaults totrue, so the waveform becomes a tab stop with slider semantics by default — this is the point of the fix. The existing click-to-focus container shortcuts are untouched. Anyone who needs the old markup can setaccessibleSeek: false.Testing
npm run buildsucceeds; changes are reflected indist/.tabindex/aria-label/aria-valueminare set;aria-valuemax/valuenow/valuetexttracksetProgress(30, 120)→"0:30 of 2:00"; → dispatchesrequest-seekwithpercent = 35/120; End →percent = 1; andaccessibleSeek: falseleaves the waveform with norole. All assertions pass.The repo has no existing test suite (and instantiating the player under test requires a canvas stub), so I verified via the harness above rather than adding a framework. Happy to adjust the approach, key bindings, step sizes, or option names to match your preferences.