From 8c56e31cad7aea715fce2db761206858ef40b52a Mon Sep 17 00:00:00 2001 From: mister-ben <1676039+mister-ben@users.noreply.github.com> Date: Wed, 28 Aug 2024 15:44:38 +0200 Subject: [PATCH] fix: check for closeable() before calling in spatialnavigation (#8832) ## 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. --- src/js/spatial-navigation.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/spatial-navigation.js b/src/js/spatial-navigation.js index 6cbde34a55..08ca9bcf4c 100644 --- a/src/js/spatial-navigation.js +++ b/src/js/spatial-navigation.js @@ -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(); }