Skip to content

Commit 2b6e4ce

Browse files
BatJannul800sebastiaan
authored andcommitted
Turn nodelist into an array and filter out elements whose parent, grandparents etc. has a .ng-hide class
1 parent e668755 commit 2b6e4ce

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbfocuslock.directive.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
// List of elements that can be focusable within the focus lock
3636
var focusableElementsSelector = '[role="button"], a[href]:not([disabled]):not(.ng-hide), button:not([disabled]):not(.ng-hide), textarea:not([disabled]):not(.ng-hide), input:not([disabled]):not(.ng-hide), select:not([disabled]):not(.ng-hide)';
3737

38-
// Grab the body element so we can add the tabbing class on it when needed
39-
var bodyElement = document.querySelector('body');
40-
4138
function getDomNodes(){
4239
infiniteEditorsWrapper = document.querySelector('.umb-editors');
4340
if(infiniteEditorsWrapper) {
@@ -47,7 +44,10 @@
4744

4845
function getFocusableElements(targetElm) {
4946
var elm = targetElm ? targetElm : target;
50-
focusableElements = elm.querySelectorAll(focusableElementsSelector);
47+
48+
// Filter out elements that are children of parents with the .ng-hide class
49+
focusableElements = [...elm.querySelectorAll(focusableElementsSelector)].filter(elm => !elm.closest('.ng-hide'));
50+
5151
// Set first and last focusable elements
5252
firstFocusableElement = focusableElements[0];
5353
lastFocusableElement = focusableElements[focusableElements.length - 1];

0 commit comments

Comments
 (0)