Fixes umbraco/Umbraco-CMS.Accessibility.Issues #63 and #61

This commit is contained in:
Karl Butler
2022-10-01 10:10:19 +01:00
committed by Michael Latouche
parent 97ac1ae629
commit bdbf9122c9
3 changed files with 22 additions and 3 deletions

View File

@@ -77,7 +77,7 @@
(function() {
'use strict';
function LightboxDirective() {
function LightboxDirective(focusLockService) {
function link(scope, el, attr, ctrl) {
@@ -88,6 +88,9 @@
el.appendTo("body");
focusLockService.addInertAttribute();
// clean up
scope.$on('$destroy', function() {
// unbind watchers
@@ -95,6 +98,9 @@
eventBindings[e]();
}
focusLockService.removeInertAttribute();
document.getElementsByClassName("umb-lightbox__close")[0].blur();
el.remove();
});
}

View File

@@ -2,7 +2,7 @@
<div class="umb-lightbox__backdrop" ng-click="close()" hotkey="esc"></div>
<button type="button" class="btn-reset umb-lightbox__close" localize="title" title="@general_close" ng-click="close()">
<button type="button" umb-auto-focus class="btn-reset umb-lightbox__close" localize="title" title="@general_close" ng-click="close()">
<umb-icon icon="icon-delete" class="umb-lightbox__control"></umb-icon>
<span class="sr-only">
<localize key="general_close">Close</localize>

View File

@@ -168,18 +168,31 @@
vm.pagination.totalPages = Math.ceil(pack.total / vm.pagination.pageSize);
});
}
var previousElement = null;
function openLightbox(itemIndex, items) {
previousElement = ( document.activeElement || document.body );
vm.lightbox = {
show: true,
items: items,
activeIndex: itemIndex
activeIndex: itemIndex,
focus: true
};
}
function closeLightbox() {
vm.lightbox.show = false;
vm.lightbox = null;
if(previousElement){
setTimeout(function(){
previousElement.focus();
previousElement = null;
}, 100)
}
}