-
Notifications
You must be signed in to change notification settings - Fork 24.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TouchableHighlight Does Not Focus AndroidTV Inside Modal #24448
Comments
Following this issue. I am struggling a bit with how to imperatively set focus on some element in AndroidTV. For example when the page is just loaded or like in your case, when Modal is opened. |
I was just facing a similar issue only on android where I have a modal and a closing TouchableOpacity. The TouchableOpacity doesn't respond to the clicks where on iOS it is working fine. To solve that I got rid of the extra wrappers above the TouchableOpacity. In your code I can see there are some unnecessary view like the below ones.
Hope this solve your issue and It seems like a bug that needs to be solved by react-native team. |
I think I tried this already before posting the bug report. But next time I spin up the dev environment I will try removing the view containers that you suggested. Thanks! |
i have the same issue, Any solution for this? |
I am getting ready to do an update on my TV apps so I am going to give it another try in the next few days. |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
@jdmueller any update on your check? |
I had some issues updating to the very latest version when I worked with it last. I was able to get mostly current however, I still had the issues the same as before with the TouchableHighlight. They still work perfectly for me on Apple TV devices. |
I'm currently facing the same problem. Any workaround this? |
Same problem here ! Did you find a workaround, or a fix, thx ! |
same problem, any fix? |
I have a similar problem. My workaround is to hide all views that are underneath the modal. |
I have a similar issue with |
Have you got a solution? |
@artemsh5432 |
@s349856186 I can not turn it on, but put the listener.
|
after briefly recreating this scenario (with a basic modal example) ... I noticed that none of your code references the usage of I suggest you to research about it https://reactnative.dev/docs/view#nextfocusright and read https://reactnative.dev/docs/building-for-tv.html I believe this is not a bug, but just your implementation is missing the logic to handle remote control focus and navigation Pass the Remote: User Input on TV Devices Similar Issue |
This is artemsh5432 solution.. It is not complete. I am trying to figure how to build this and hopefully find a way to contribute to tv in the future.. import React, { Component, useState } from "react";
import {
Alert,
Modal,
StyleSheet,
Text,
TouchableHighlight,
TouchableOpacity,
View,
TVEventHandler,
findNodeHandle,
Button
} from "react-native";
class App extends Component {
constructor(props) {
super(props);
this.state = { isFocus: false };
}
disableTVEventHandler() {
if (this.evtHandler) {
this.evtHandler.disable();
delete this.evtHandler;
}
}
enableTVEventHandler = () => {
this.evtHandler = new TVEventHandler();
this.evtHandler.enable(this, this.handleTVRemoteEvent);
}
handleTVRemoteEvent = (cmp, event) => {
const { eventType, tag } = event;
if (tag !== this.nodeHandle) {
return;
}
if (eventType === "left") {
if (this.props.onLeft !== undefined) {
this.props.onLeft();
}
}
if (eventType === "right" && event.eventKeyAction === 1) {
if (this.props.onRight !== undefined) {
this.props.onRight();
}
}
if (eventType === "focus") {
this.setState({ isFocus: true });
if (this.props.focus !== undefined) {
this.props.focus();
}
}
if (eventType === "select") {
if (this.props.onTouch !== undefined) {
this.props.onTouch();
}
}
if (eventType === "blur") {
this.setState({ isFocus: false });
}
}
componentDidMount = () => {
this.nodeHandle = findNodeHandle(this.myRef)
this.enableTVEventHandler();
}
componentWillUnmount() {
this.disableTVEventHandler();
}
render() {
const { children, hide, ...props } = this.props;
var { isFocus } = this.state;
console.debug('focusing, isFocus', isFocus);
return (
<TouchableHighlight
touchableHandleActivePressIn
hasTVPreferredFocus={true}
ref={this.myRef}
style={{ backgroundColor: isFocus ? 'blue' : 'red' }}
onPressIn={() => this.setState({isFocus: true})}
onPressOut={() => this.setState({isFocus: true})}>
<View>
<Text>TEsting</Text>
</View>
</TouchableHighlight>
)
}
};
const styles = StyleSheet.create({
});
export default App; |
@fabriziobertoglio1987 I do not understand how this code works
|
I am facing the same issue when we have any Touchable Components in the Modal |
@artemsh5432 I'm kind of giving up on this issue, I believe here the issue is on the missing/incomplete documentation... we need additional guide at https://github.com/facebook/react-native-website (the docs you see at reactnative.dev/) ... so maybe you should open an issue there and reference it I don't know the solution to your problem, but here are my points:
To better understand this concept you may read more about building apps on android tv and for example Netflix. I just want to tell you that I experimented the same bug in Spotify tv app... when I move between songs they do not highlight my cursor because that part of the screen does not support dpad navigation
|
@fabriziobertoglio1987 I have a list of items, I think it will be very bad for him |
I am doing Android TV development now, and I have encountered the problem that I cannot focus TouchableHighlight when switching the remote control in modal. Is your problem solved now? If it is solved, can you share your solution? thank you very much. |
I am doing Android TV development now, and I have encountered the problem that I cannot focus TouchableHighlight when switching the remote control in modal. Is your problem solved now? If it is solved, can you share your solution? thank you very much. |
I am doing Android TV development now, and I have encountered the problem that I cannot focus TouchableHighlight when switching the remote control in modal. Is your problem solved now? If it is solved, can you share your solution? thank you very much. |
I am doing Android TV development now, and I have encountered the problem that I cannot focus TouchableHighlight when switching the remote control in modal. Is your problem solved now? If it is solved, can you share your solution? thank you very much. |
I am doing Android TV development now, and I have encountered the problem that I cannot focus TouchableHighlight when switching the remote control in modal. Is your problem solved now? If it is solved, can you share your solution? thank you very much. |
I am doing Android TV development now, and I have encountered the problem that I cannot focus TouchableHighlight when switching the remote control in modal. Is your problem solved now? If it is solved, can you share your solution? thank you very much. |
@wanglaohushiwo, Hello, Sorry, but this problem, as well as the defocusing problem, remains unanswered from the developers. |
Thank you for replying me the first time, if there is no modal, is there any good alternative
…------------------ 原始邮件 ------------------
发件人: "artemsh5432"<notifications@github.com>;
发送时间: 2020年5月29日(星期五) 中午1:22
收件人: "facebook/react-native"<react-native@noreply.github.com>;
抄送: " "<1024511894@qq.com>; "Mention"<mention@noreply.github.com>;
主题: Re: [facebook/react-native] TouchableHighlight Does Not Focus AndroidTV Inside Modal (#24448)
@wanglaohushiwo, Hello, Sorry, but this problem, as well as the defocusing problem, remains unanswered from the developers.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@wanglaohushiwo, Currently, I know that I have only 2 focus options:
I think that for Android tv it is better to change the framework. But I don’t know how things are on other platforms, but everything is not very good here |
I tried it here, it doesn't seem to work |
Same problem here, and no solution found. |
Has anyone found any solution? |
Hey all please check out https://github.com/react-native-community/react-native-tvos for future development for react-native-tvos |
please use this version of react-native-TV 0.64.2-3. Android Modal Focus issue is resolved in that. |
Use view with absolute position with zindex and it will work like a modal |
🐛 Bug Report
I am using a modal to display a page of information using TouchableHighlights. I have noticed that it says hasTVPreferredFocus={true} is only for tvOS but it does seem to work on AndroidTV anyways, but not inside the modal. It is working on my main home screen the d-pad works correctly and moves between the TouchableHighlights on the page. However, as soon as I open the modal that contains 4 TouchableHighlight buttons they refuse to focus and you cannot navigate to any of the items. The entire app runs correctly on tvOS but on Android TV emulator and physical device it will not work. On emulator you can click the screen and it will work correctly. I have tried hasTVPreferredFocus={true} and it will not work inside the modal. You can use the example modal code from React Native adding a TouchableHighlight and it does not work for AndroidTV.
To Reproduce
Setup basic project using react-native init using the example modal code that launches from a main home screen. Place a TouchableHighlight inside the modal and the focus will not change even with hasTVPreferredFocus={true} on ATV. My modals are imported from separate class components.
Expected Behavior
Using hasTVPreferredFocus={true} the d-pad should work between the touchable highlights just like it does on tvOS. tvOS correctly focuses on the first TouchableHighlight even without hasTVPreferredFocus: True.
Code Example using React Native modal code from docs:
Here is my touchable code. I have tried using a ref as well.
Environment
React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Memory: 385.13 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.8.0 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 24, 26, 27, 28
Build Tools: 24.0.0, 26.0.0, 28.0.3
System Images: android-27 | Android TV Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.4 => 0.59.4
npmGlobalPackages:
react-native-cli: 2.0.1
react-native: 0.59.4
I will attach images to further explain my issue. The main screen is not within a modal and you can see the d-pad works and remote works tvOS and ATV. However, on ATV neither of the modals with TouchableHighlights inside will receive focus making the page unresponsive.
The text was updated successfully, but these errors were encountered: