From 04868c13312c96f6c123716c9a04d6b03c544a4e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 19 Nov 2021 16:21:50 +0100 Subject: Fix player menu keyboard navigation --- .../assets/player/videojs-components/settings-menu-button.ts | 3 +++ .../assets/player/videojs-components/settings-menu-item.ts | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'client/src/assets/player/videojs-components') diff --git a/client/src/assets/player/videojs-components/settings-menu-button.ts b/client/src/assets/player/videojs-components/settings-menu-button.ts index 50e25c004..c9990af1c 100644 --- a/client/src/assets/player/videojs-components/settings-menu-button.ts +++ b/client/src/assets/player/videojs-components/settings-menu-button.ts @@ -150,6 +150,9 @@ class SettingsButton extends Button { this.dialog.show() this.setDialogSize(this.getComponentSize(this.menu)) + + const firstChild = this.menu.children()[0] + if (firstChild) firstChild.focus() } hideDialog () { diff --git a/client/src/assets/player/videojs-components/settings-menu-item.ts b/client/src/assets/player/videojs-components/settings-menu-item.ts index 67e71b4e2..31d42c456 100644 --- a/client/src/assets/player/videojs-components/settings-menu-item.ts +++ b/client/src/assets/player/videojs-components/settings-menu-item.ts @@ -101,7 +101,7 @@ class SettingsMenuItem extends MenuItem { if (event.type === 'tap') { target = event.target } else { - target = event.currentTarget + target = event.currentTarget || event.target } if (target?.classList.contains('vjs-back-button')) { @@ -124,7 +124,8 @@ class SettingsMenuItem extends MenuItem { */ createEl () { const el = videojs.dom.createEl('li', { - className: 'vjs-menu-item' + className: 'vjs-menu-item', + tabIndex: -1 }) this.settingsSubMenuTitleEl_ = videojs.dom.createEl('div', { @@ -170,6 +171,9 @@ class SettingsMenuItem extends MenuItem { }, 0) this.settingsButton.setDialogSize(this.size) + + const firstChild = this.subMenu.menu.children()[0] + if (firstChild) firstChild.focus() } else { videojs.dom.addClass(this.settingsSubMenuEl_, 'vjs-hidden') } @@ -244,6 +248,9 @@ class SettingsMenuItem extends MenuItem { // this triggers CSS Transition event this.setMargin() mainMenuEl.style.opacity = '1' + + const firstChild = this.mainMenu.children()[0] + if (firstChild) firstChild.focus() }, 0) } -- cgit v1.2.3