Skip to content

Commit

Permalink
Turn nodelist into an array and filter out elements whose parent, gra…
Browse files Browse the repository at this point in the history
…ndparents etc. has a .ng-hide class
  • Loading branch information
BatJan authored and nul800sebastiaan committed Oct 20, 2021
1 parent e668755 commit 2b6e4ce
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
// List of elements that can be focusable within the focus lock
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)';

// Grab the body element so we can add the tabbing class on it when needed
var bodyElement = document.querySelector('body');

function getDomNodes(){
infiniteEditorsWrapper = document.querySelector('.umb-editors');
if(infiniteEditorsWrapper) {
Expand All @@ -47,7 +44,10 @@

function getFocusableElements(targetElm) {
var elm = targetElm ? targetElm : target;
focusableElements = elm.querySelectorAll(focusableElementsSelector);

// Filter out elements that are children of parents with the .ng-hide class
focusableElements = [...elm.querySelectorAll(focusableElementsSelector)].filter(elm => !elm.closest('.ng-hide'));

// Set first and last focusable elements
firstFocusableElement = focusableElements[0];
lastFocusableElement = focusableElements[focusableElements.length - 1];
Expand Down

0 comments on commit 2b6e4ce

Please sign in to comment.