Skip to content

A platform for community discussion. Free, open, simple.

A11Y: add role to video thumbnail button (#35326)

Kris18f9bf787a7d
diff --git a/plugins/discourse-lazy-videos/assets/javascripts/discourse/components/lazy-video.gjs b/plugins/discourse-lazy-videos/assets/javascripts/discourse/components/lazy-video.gjs
index d12500d3a3d..5525bca614a 100644
--- a/plugins/discourse-lazy-videos/assets/javascripts/discourse/components/lazy-video.gjs
+++ b/plugins/discourse-lazy-videos/assets/javascripts/discourse/components/lazy-video.gjs
@@ -5,6 +5,7 @@ import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { htmlSafe } from "@ember/template";
import concatClass from "discourse/helpers/concat-class";
+import { i18n } from "discourse-i18n";
import LazyIframe from "./lazy-iframe";
export default class LazyVideo extends Component {
@@ -27,7 +28,7 @@ export default class LazyVideo extends Component {
@action
onKeyPress(event) {
- if (event.key === "Enter") {
+ if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
this.loadEmbed();
}
@@ -55,8 +56,13 @@ export default class LazyVideo extends Component {
{{else}}
<div
{{on "click" this.loadEmbed}}
- {{on "keypress" this.loadEmbed}}
+ {{on "keypress" this.onKeyPress}}
+ role="button"
tabindex="0"
+ aria-label={{i18n
+ "lazy_videos.play_video"
+ }}
style={{this.thumbnailStyle}}
class={{concatClass "video-thumbnail" @videoAttributes.providerName}}
>
diff --git a/plugins/discourse-lazy-videos/config/locales/client.en.yml b/plugins/discourse-lazy-videos/config/locales/client.en.yml
new file mode 100644
index 00000000000..25430715af1
--- /dev/null
+++ b/plugins/discourse-lazy-videos/config/locales/client.en.yml
@@ -0,0 +1,4 @@
+en:
+ js:
+ lazy_videos:
+ play_video: "Play %{title}"