Skip to content

Commit

Permalink
Fix logic for retrieving lastKnownElement
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpnielsen authored and nul800sebastiaan committed Apr 26, 2024
1 parent 2bb56f1 commit cae106b
Showing 1 changed file with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,27 @@

// If an infinite editor is being closed then we reset the focus to the element that triggered the the overlay
if(closingEditor){

// If there is only one editor open, search for the "editor-info" inside it and set focus on it
// This is relevant when a property editor has been selected and the editor where we selected it from
// is closed taking us back to the first layer
// Otherwise set it to the last element in the lastKnownFocusedElements array
if(infiniteEditors && infiniteEditors.length === 1){
var editorInfo = infiniteEditors[0].querySelector('.editor-info');
if(infiniteEditors && infiniteEditors.length === 1 && editorInfo !== null) {
lastKnownElement = editorInfo;

// Clear the array
clearLastKnownFocusedElements();
}
var editorInfo = (infiniteEditors && infiniteEditors.length === 1)
? infiniteEditors[0].querySelector('.editor-info')
: null;

if(editorInfo !== null){
lastKnownElement = editorInfo;

// Clear the array
clearLastKnownFocusedElements();
}
else {
var lastItemIndex = $rootScope.lastKnownFocusableElements.length - 1;
lastKnownElement = $rootScope.lastKnownFocusableElements[lastItemIndex];
else{
var lastIndex = $rootScope.lastKnownFocusableElements.length - 1;
lastKnownElement = $rootScope.lastKnownFocusableElements[lastIndex];

// Remove the last item from the array so we always set the correct lastKnowFocus for each layer
$rootScope.lastKnownFocusableElements.splice(lastItemIndex, 1);
// Remove the last item from the array so we always set the correct lastKnowFocus for each layer
$rootScope.lastKnownFocusableElements.splice(lastIndex, 1);
}

// Update the lastknowelement variable here
Expand Down

0 comments on commit cae106b

Please sign in to comment.