From 2aff0fc6feae603b927ab13d1a71849b340e438a Mon Sep 17 00:00:00 2001 From: Freeplay Date: Wed, 17 May 2023 13:46:00 -0400 Subject: [PATCH] Allow pressing esc to close lightbox --- packages/client/src/components/MkMediaList.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/client/src/components/MkMediaList.vue b/packages/client/src/components/MkMediaList.vue index 6ee427388..237afc675 100644 --- a/packages/client/src/components/MkMediaList.vue +++ b/packages/client/src/components/MkMediaList.vue @@ -166,6 +166,8 @@ onMounted(() => { lightbox.on("afterInit", () => { history.pushState(null, "", location.href); addEventListener("popstate", close); + // This is a workaround. Not sure why, but when clicking to open, it doesn't move focus to the photoswipe. Preventing using esc to close. However when using keyboard to open it already focuses the lightbox fine. + lightbox.pswp.element.focus(); }) lightbox.on("close", () => { removeEventListener("popstate", close);