From 139ec51dde72a10b5818206a0fe189c029d329ed Mon Sep 17 00:00:00 2001 From: Varun Gujarathi Date: Wed, 10 Jan 2024 11:15:57 +0530 Subject: [PATCH] fix: add eventType support for touch devices (#3508) fixes Not selectable items in quality settings menu #3368 --- web/components/video/settings-menu.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/web/components/video/settings-menu.ts b/web/components/video/settings-menu.ts index 68e82f77e..f4403f1fa 100644 --- a/web/components/video/settings-menu.ts +++ b/web/components/video/settings-menu.ts @@ -58,10 +58,17 @@ export function createVideoSettingsMenuButton( }); }); + let clickEvent; + if ('ontouchstart' in window) { + clickEvent = 'touchend'; // Use touchend event for touch devices + } else { + clickEvent = 'click'; // Use click for all other devices + } + for (let i = 0; i < items.length; i += 1) { const item = items[i]; // Quality selected - item.on('click', () => { + item.on(clickEvent, () => { // If for some reason tech doesn't exist, then don't do anything if (!tech) { console.warn('Invalid attempt to access null player tech'); @@ -77,7 +84,7 @@ export function createVideoSettingsMenuButton( }); } - defaultAutoItem.on('click', () => { + defaultAutoItem.on(clickEvent, () => { // Re-enable all representations. tech.vhs.representations().forEach(rep => { rep.enabled(true);