Skip to content

Commit

Permalink
fix: check for closeable() before calling in spatialnavigation (#8832)
Browse files Browse the repository at this point in the history
## Description
Passing the back key causes an error in spatial navigation if the event
target does not have a `closeable` function.

## Specific Changes proposed
Add a check before calling.
  • Loading branch information
mister-ben authored Aug 28, 2024
1 parent 5fac9e1 commit 8c56e31
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/js/spatial-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ class SpatialNavigation extends EventTarget {
const action = SpatialNavKeyCodes.getEventName(actualEvent);

this.performMediaAction_(action);
} else if (SpatialNavKeyCodes.isEventKey(actualEvent, 'Back') && event.target && event.target.closeable()) {
} else if (SpatialNavKeyCodes.isEventKey(actualEvent, 'Back') &&
event.target && typeof event.target.closeable === 'function' && event.target.closeable()) {
actualEvent.preventDefault();
event.target.close();
}
Expand Down

0 comments on commit 8c56e31

Please sign in to comment.