gallery: fix hotkeys + focus

This commit is contained in:
ed 2021-07-14 09:35:50 +02:00
parent 18676c5e65
commit af5169f67f
2 changed files with 5 additions and 10 deletions

View file

@ -83,7 +83,7 @@ window.baguetteBox = (function () {
var trapFocusInsideOverlay = function (event) { var trapFocusInsideOverlay = function (event) {
if (overlay.style.display === 'block' && (overlay.contains && !overlay.contains(event.target))) { if (overlay.style.display === 'block' && (overlay.contains && !overlay.contains(event.target))) {
event.stopPropagation(); event.stopPropagation();
initFocus(); closeButton.focus();
} }
}; };
@ -378,16 +378,8 @@ window.baguetteBox = (function () {
options.onChange(currentIndex, imagesElements.length); options.onChange(currentIndex, imagesElements.length);
} }
documentLastFocus = document.activeElement; documentLastFocus = document.activeElement;
initFocus();
isOverlayVisible = true;
}
function initFocus() {
if (options.buttons) {
previousButton.focus();
} else {
closeButton.focus(); closeButton.focus();
} isOverlayVisible = true;
} }
function hideOverlay(e) { function hideOverlay(e) {

View file

@ -1756,6 +1756,9 @@ document.onkeydown = function (e) {
if (e.ctrlKey || e.altKey || e.metaKey || e.isComposing) if (e.ctrlKey || e.altKey || e.metaKey || e.isComposing)
return; return;
if (QS('#baguetteBox-overlay.visible'))
return;
var k = e.code + '', pos = -1, n; var k = e.code + '', pos = -1, n;
if (e.shiftKey && k != 'KeyA' && k != 'KeyD') if (e.shiftKey && k != 'KeyA' && k != 'KeyD')