Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix accessibility of progressive enhancement pattern #177

Closed
wants to merge 1 commit into from

Conversation

delucis
Copy link
Contributor

@delucis delucis commented Apr 11, 2024

In #124 I naïvely “fixed” the issue of the play button being a link when following the progressive enhancement pattern by removing the href attribute.

However, this introduced an accessibility issue: <a> without an href attribute is considered non-interactive, and therefore can’t be tabbed to by keyboard users, preventing them from playing the video.

This PR seeks to fix this more correctly by replacing an <a> element entirely with a <button> when the custom element loads. This preserves interactive semantics.

To test I loaded the progressive enhancement example. Before this change, the play button is not focusable with the keyboard. After this change, the play button can be focused as expected.

@jrouleau
Copy link

The replaceWith will also remove the element's children. The default span will then be recreated in the following block, but as the user may have customised this, we should probably also move the children to the new button element

@paulirish
Copy link
Owner

sorry.. i got distracted with @scottjehl's new PR that does the same thing: #183...
i didnt realize you had already made this! Really appreciate the PR!

I somewhat do prefer the diff in 183 though... That said, please holler if there's a behavior difference we need to address!

@paulirish paulirish closed this Aug 10, 2024
@paulirish
Copy link
Owner

Really appreciate the PR!

also... what a delight that you have 2 PRs exactly 2 years apart:

image

image

April 11th is Annual lite-youtube PR Day! ❤️

@delucis
Copy link
Contributor Author

delucis commented Aug 10, 2024

Oh my, I hadn’t noticed — better mark my calendar for next year 😁

Happy to see this fixed 💖

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.

3 participants