diff --git a/packages/example/App.tsx b/packages/example/App.tsx index 46982270..92eced5b 100644 --- a/packages/example/App.tsx +++ b/packages/example/App.tsx @@ -78,8 +78,6 @@ function App(): JSX.Element { - - { const goBackOnBackPress = useCallback( (pressedKey: SupportedKeys) => { + if (!navigation.isFocused) { + return false; + } if (pressedKey !== SupportedKeys.Back) return false; if (navigation.canGoBack()) { navigation.goBack(); diff --git a/packages/example/src/components/Page.tsx b/packages/example/src/components/Page.tsx index 895511ea..a6a701ad 100644 --- a/packages/example/src/components/Page.tsx +++ b/packages/example/src/components/Page.tsx @@ -3,7 +3,8 @@ import { useIsFocused } from '@react-navigation/native'; import { ReactNode, useCallback, useEffect } from 'react'; import { SpatialNavigationRoot, useLockSpatialNavigation } from 'react-tv-space-navigation'; import { useMenuContext } from './Menu/MenuContext'; -import { Keyboard } from 'react-native'; +import { BackHandler, Keyboard } from 'react-native'; +import { GoBackConfiguration } from './GoBackConfiguration'; type Props = { children: ReactNode }; @@ -51,6 +52,7 @@ export const Page = ({ children }: Props) => { isActive={isActive} onDirectionHandledWithoutMovement={onDirectionHandledWithoutMovement} > + {children} diff --git a/packages/example/src/components/remote-control/RemoteControlManager.android.ts b/packages/example/src/components/remote-control/RemoteControlManager.android.ts index 200fb36f..6e935c13 100644 --- a/packages/example/src/components/remote-control/RemoteControlManager.android.ts +++ b/packages/example/src/components/remote-control/RemoteControlManager.android.ts @@ -19,6 +19,7 @@ class RemoteControlManager implements RemoteControlManagerInterface { 66: SupportedKeys.Enter, 23: SupportedKeys.Enter, 67: SupportedKeys.Back, + 4: SupportedKeys.Back, }[keyEvent.keyCode]; if (!mappedKey) {