bamlab / bamlab/react-tv-space-navigation
It is not possible to select the focusable element for the 2nd time when we return to the previous screen.
- Dominant language
- TypeScript
- Stars
- 319
- Forks
- 46
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
This is played in android TV (android studio emulator). Everything works correctly in the web version. I use expo-route for navigation. But I don't think that's the point.
https://github.com/user-attachments/assets/5709a79f-ce96-4ea8-9f55-a679c284846c
If you click on any place in the emulator, the bug does not play, but you will not be able to do this on a real TV)
**To Reproduce**
configureRemoteControl (I used TVEventHandler, react-native-keyevent not work for me)
```tsx
SpatialNavigation.configureRemoteControl({
remoteControlSubscriber: (callback) => {
const mapping: Record = {
right: Directions.RIGHT,
left: Directions.LEFT,
up: Directions.UP,
down: Directions.DOWN,
select: Directions.ENTER,
}
const eventId = TVEventHandler.addListener((keyEvent) => {
if (!keyEvent) {
return
}
const mapped =
mapping[keyEvent.eventType] && keyEvent.eventKeyAction === 1 ? mapping[keyEvent.eventType] : null
callback(mapped)
})
return eventId
},
remoteControlUnsubscriber: (eventId: EventSubscription) => {
eventId?.remove()
},
})
```
index file code
```tsx
const Item = () => {
const router = useRouter()
return (
{
router.push('search')
}}
>
{({ isFocused }) => {
return (
)
}}
)
}
export default function Index() {
return (
)
}
```
**Expected behavior**
onSelect is triggered when we click on the element a second time
**Version and OS**
- expo: ~52.0.17
- react-native-tvos : ~0.76.3-0
- react-tv-space-navigation: ^5.1.0
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the navigation flow from the index file code on the Android TV emulator, using the configureRemoteControl setup and SpatialNavigationFocusableView items. Trace focus restoration after router.push('search') and returning to the previous screen; done means onSelect fires when the previously focused element is selected a second time without mouse or pointer input.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, react-native, typescript
- Domain
- frontend, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100