Skip to content
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

Focusing issue on hidden (display : none) element #175

Open
alham0046 opened this issue Dec 21, 2024 · 1 comment
Open

Focusing issue on hidden (display : none) element #175

alham0046 opened this issue Dec 21, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@alham0046
Copy link

Describe the bug
Initially the focus is on TvShows tab. When i am navigating to Movies tab and pressing down key, TvShows tab's element should hide but here Movies tab's element is layering over TvShows tab's element and the focus still remains on TvShows tab's element which should be on Movies tab's element. Basically i am trying to make custom top tab navigator. I have used SpatialNavigationRoot in its parent component

To Reproduce

const MainScreen = () => {
    const mainFocus = useSelector((state) => state.currentFocus.focusedType)
    const [tabFocusArr, setTabFocusArr] = useState([])
    useEffect(() => {
        if (!tabFocusArr.includes(mainFocus)) {
            setTabFocusArr([...tabFocusArr, mainFocus])
        }
    }, [mainFocus])

    return (
        <View className='w-full'>
            <SpatialNavigationNode>{tabFocusArr.includes('TvShows') && <View className ={`${mainFocus == 'TvShows' ? 'flex' : 'hidden'}`} ><Tvshows/></View>}</SpatialNavigationNode>
            <SpatialNavigationNode>{tabFocusArr.includes('Movies') && <View className={`${mainFocus == 'Movies' ? 'flex' : 'hidden'}`} ><Movies/></View>}</SpatialNavigationNode>
        </View>
    )
}

export default memo(MainScreen)

Expected behavior
When i focus on videos tab the photos tab's element and when i press down it should focus on videos tab's element

Version and OS

  • Library version: [e.g. 1.0.0]
  • React Native version: [e.g. 0.76.3]
  • OS [tvOS]
@alham0046 alham0046 added the bug Something isn't working label Dec 21, 2024
@pierpo
Copy link
Member

pierpo commented Dec 29, 2024

Hi!

I do not fully understand your issue because I do not understand the layout 😁 What do you mean by pressing down? What is supposed to happen, is your screen beneath your tab bar?
Also, what is your state.currentFocus.focusedType, and how do you update it?

If you can't provide any screenshot, can you do at least a little drawing of your layout? It's quite hard to help otherwise 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants