Allow pressing esc to close lightbox
This commit is contained in:
parent
4bebe2187f
commit
da522482ac
1 changed files with 2 additions and 0 deletions
|
@ -166,6 +166,8 @@ onMounted(() => {
|
||||||
lightbox.on("afterInit", () => {
|
lightbox.on("afterInit", () => {
|
||||||
history.pushState(null, "", location.href);
|
history.pushState(null, "", location.href);
|
||||||
addEventListener("popstate", close);
|
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", () => {
|
lightbox.on("close", () => {
|
||||||
removeEventListener("popstate", close);
|
removeEventListener("popstate", close);
|
||||||
|
|
Loading…
Reference in a new issue