Skip to content

Commit

Permalink
Fixing hasFocusableChild (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrian-wozniak authored Jul 31, 2023
1 parent a6feb4d commit 1c329bd
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/SpatialNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,19 @@ class SpatialNavigationService {
if (focusKey === this.focusKey) {
this.setFocus(focusKey);
}

/**
* Parent nodes are created after children, and child may focus itself.
* If so, it's required to check if parent lies on a path to focused child.
*/
let currentComponent = this.focusableComponents[this.focusKey];
while (currentComponent) {
if (currentComponent.parentFocusKey === focusKey) {
this.updateParentsHasFocusedChild(this.focusKey, {});
break;
}
currentComponent = this.focusableComponents[currentComponent.parentFocusKey];
}
}

removeFocusable({ focusKey }: FocusableComponentRemovePayload) {
Expand Down

0 comments on commit 1c329bd

Please sign in to comment.