From 18d341f82acf843ff830d1bf3d44678f3f2eda52 Mon Sep 17 00:00:00 2001 From: Mikhail Kozlov Date: Thu, 18 May 2023 11:41:45 -0700 Subject: [PATCH] fix(Utils): return null when SP not found --- src/utils/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/index.ts b/src/utils/index.ts index e87b167..a1fd37d 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -22,7 +22,7 @@ export function findSP(): Window { if (document.title == 'SP') return window; // new (SP as popup) const navTrees = getGamepadNavigationTrees(); - return navTrees.find((x: any) => x.m_ID == 'root_1_').Root.Element.ownerDocument.defaultView; + return navTrees?.find((x: any) => x.m_ID == 'root_1_').Root.Element.ownerDocument.defaultView; } /** @@ -38,5 +38,5 @@ export function getFocusNavController(): any { export function getGamepadNavigationTrees(): any { const focusNav = getFocusNavController(); const context = focusNav.m_ActiveContext || focusNav.m_LastActiveContext; - return context.m_rgGamepadNavigationTrees; + return context?.m_rgGamepadNavigationTrees; }