Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix video tabbing

Manav Rathi6b912282732f
diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts
index b11ae787b2..99ca27f754 100644
--- a/web/packages/gallery/components/viewer/photoswipe.ts
+++ b/web/packages/gallery/components/viewer/photoswipe.ts
@@ -539,6 +539,19 @@ export class FileViewerPhotoSwipe {
pswp.on("change", () => {
const itemData = currSlideData();
+ // For each slide ("item holder"), mirror the "aria-hidden" state
+ // into the "inert" property so that keyboard navigation via tabs
+ // does not cycle through to the hidden slides (e.g. if the hidden
+ // slide is a video element with browser provided controls).
+
+ pswp.mainScroll.itemHolders.forEach(({ el }) => {
+ if (el.getAttribute("aria-hidden") == "true") {
+ el.setAttribute("inert", "");
+ } else {
+ el.removeAttribute("inert");
+ }
+ });
+
// Clear existing listeners, if any.
if (videoVideoEl && onVideoPlayback) {
videoVideoEl.removeEventListener("play", onVideoPlayback);