Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/async-focus-blur-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@noriginmedia/norigin-spatial-navigation-core": patch
---

Fix for a race condition where `onIntermediateNodeBecameBlurred` and `onIntermediateNodeBecameFocused` functions could throw a _TypeError_ if the component no longer existed once promises resolve.
4 changes: 2 additions & 2 deletions packages/core/src/SpatialNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@
this.layoutAdapter = new LayoutAdapterClass(this);
} else {
if (useGetBoundingClientRect) {
console.warn(

Check warning on line 790 in packages/core/src/SpatialNavigation.ts

View workflow job for this annotation

GitHub Actions / Test

Unexpected console statement
'useGetBoundingClientRect is deprecated. Please use layoutAdapter API instead.'
);
this.layoutAdapter = new GetBoundingClientRectAdapter(this);
Expand Down Expand Up @@ -1188,7 +1188,7 @@

if (this.debug) {
if (nextComponent != null && !siblings.includes(nextComponent)) {
console.warn(

Check warning on line 1191 in packages/core/src/SpatialNavigation.ts

View workflow job for this annotation

GitHub Actions / Test

Unexpected console statement
`nextFocusResolver returned an invalid component. This will result in lost focus. Check the "nextFocusResolver" implementation in component with focusKey: ${parentFocusKey}`
);
}
Expand All @@ -1208,7 +1208,7 @@
).length;

if (focusableSiblingCount >= 2) {
console.warn(

Check warning on line 1211 in packages/core/src/SpatialNavigation.ts

View workflow job for this annotation

GitHub Actions / Test

Unexpected console statement
`measureChildrenLayout is false but no nextFocusResolver is set for component with focusKey: ${parentFocusKey}. Default coordinate-based navigation requires fresh layout data and may behave incorrectly.`
);
}
Expand Down Expand Up @@ -1776,7 +1776,7 @@
) {
if (this.isParticipatingFocusableComponent(focusKey)) {
this.getNodeLayoutByFocusKey(focusKey).then((layout) => {
this.focusableComponents[focusKey].onFocus(layout, focusDetails);
this.focusableComponents[focusKey]?.onFocus(layout, focusDetails);
});
}
}
Expand All @@ -1787,7 +1787,7 @@
) {
if (this.isParticipatingFocusableComponent(focusKey)) {
this.getNodeLayoutByFocusKey(focusKey).then((layout) => {
this.focusableComponents[focusKey].onBlur(layout, focusDetails);
this.focusableComponents[focusKey]?.onBlur(layout, focusDetails);
});
}
}
Expand Down
Loading