From 73e50ce2bd318706d992e3c31ccd21faa67a4f51 Mon Sep 17 00:00:00 2001 From: Patrick Stark Date: Fri, 26 Apr 2024 14:27:03 +0200 Subject: [PATCH] removed setByKeyboard on tracks since it sets a wrong focus --- src/js/features/tracks.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/js/features/tracks.js b/src/js/features/tracks.js index f9252a854..6f0a972cc 100644 --- a/src/js/features/tracks.js +++ b/src/js/features/tracks.js @@ -147,13 +147,12 @@ Object.assign(MediaElementPlayer.prototype, { // if only one language then just make the button a toggle if (t.options.toggleCaptionsButtonWhenOnlyOne && subtitles.length === 1) { player.captionsButton.classList.add(`${t.options.classPrefix}captions-button-toggle`); - player.captionsButton.addEventListener('click', (e) => { + player.captionsButton.addEventListener('click', () => { let trackId = 'none'; if (player.selectedTrack === null) { trackId = player.getSubtitles()[0].trackId; } - const keyboard = e.keyCode || e.which; - player.setTrack(trackId, (typeof keyboard !== 'undefined')); + player.setTrack(trackId); }); } else { const @@ -436,9 +435,8 @@ Object.assign(MediaElementPlayer.prototype, { /** * * @param {String} trackId, or "none" to disable captions - * @param {Boolean} setByKeyboard */ - setTrack (trackId, setByKeyboard) { + setTrack (trackId) { const t = this, radios = t.captionsButton.querySelectorAll('input[type="radio"]'), @@ -478,12 +476,6 @@ Object.assign(MediaElementPlayer.prototype, { const event = createEvent('captionschange', t.media); event.detail.caption = t.selectedTrack; t.media.dispatchEvent(event); - - if (!setByKeyboard) { - setTimeout(function() { - t.getElement(t.container).focus(); - }, 500); - } }, /** @@ -558,9 +550,7 @@ Object.assign(MediaElementPlayer.prototype, { const target = document.getElementById(`${autoplayTrack.trackId}-btn`) if (target) { target.checked = true; - const clickEvent = createEvent('click', target); - clickEvent.stopPropagation(); - target.dispatchEvent(clickEvent); + target.dispatchEvent(createEvent('click', target)); } } }