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

ScrollView doesn't scroll to focused element #28509

Open
Zahoq opened this issue Apr 3, 2020 · 4 comments
Open

ScrollView doesn't scroll to focused element #28509

Zahoq opened this issue Apr 3, 2020 · 4 comments
Labels
Component: ScrollView Help Wanted :octocat: Issues ideal for external contributors. Needs: Attention Issues where the author has responded to feedback. Newer Patch Available Platform: Android Android applications.

Comments

@Zahoq
Copy link
Contributor

Zahoq commented Apr 3, 2020

Environment

Android API: 28
Device: AndroidTV emulator and Xiaomi MI BOX
React Native: 0.61.5

Description

Sometimes ScrollView doesn't scroll to currently focused element on AndroidTV devices. Looks like issue is triggered because of two scroll events, one from ReactScrollView.java arrowScroll method and one from requestChildFocus. Issue seems to occur only when scrolling on the bottom of ScrollView.

React Native version:

"0.61.5"

Steps To Reproduce

  1. Navigate with keyboard/remote controller up and down on between last rows of ScrollView.

Expected Results

Scroll follows focused element

Snack, code example, screenshot, or link to a repository:

App.ts example:

import React from 'react';
import {View, StyleProp, TextStyle, ViewStyle, TouchableOpacity, ScrollView, Text} from 'react-native';
const styles: {[name: string]: StyleProp<ViewStyle> | StyleProp<TextStyle>} = {
  container: {
    position: 'absolute',
    width: '100%',
    height: '100%',
    backgroundColor: '#000',
    justifyContent: 'flex-end',
    alignContent: 'center'
  }
};
const rows = [1,2,3,4,5,6,7,8,9];
const columns = ['a', 'b', 'c', 'd', 'e', 'f'];
type Props = {
  text: string;
  number: number;
}
const MyButton = (props: Props) => {
  return (
    <TouchableOpacity
      style={{width: 200, height: 200, margin: 50, backgroundColor: `rgba(100,255,0,0.3)`}}
      key={props.text + props.number}
      onPress={() => {}}
    >
      <Text>{props.text + props.number}</Text>
    </TouchableOpacity>
  );
};
const App = () => {
  return (
    <View style={styles.container}>
      <ScrollView>
        {rows.map((number) => (
          <ScrollView
            horizontal={true}
            key={'scrollview' + number}
          >
            {columns.map((text) => <MyButton text={text} number={number} key={text + number} />)}
          </ScrollView>
        ))
        }
      </ScrollView>
    </View>
  );
};
export default App;

In gif below i navigated up and down only:
brokenScrolling2

@github-actions
Copy link

github-actions bot commented Apr 7, 2020

⚠️ Using Old Version
ℹ️ It looks like you are using an older version of React Native. Please upgrade to the latest version, and verify if the issue persists. If it does not, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the current release.

@hramos
Copy link
Contributor

hramos commented Apr 7, 2020

Android TV is not officially supported, though folks from the community have contributed code to enable it. I'm going to label this issue as something that would need to be fixed by a pull request from the community if needed.

@hramos hramos added the Help Wanted :octocat: Issues ideal for external contributors. label Apr 7, 2020
@falxcerebri
Copy link

@Zahoq could you link a minimal reproduction repo (preferably on GitHub as well)?

@Zahoq
Copy link
Contributor Author

Zahoq commented Apr 11, 2020

repo: https://github.com/Zahoq/ScrollViewBug
Issue still reproduces on react-native: 0.62.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: ScrollView Help Wanted :octocat: Issues ideal for external contributors. Needs: Attention Issues where the author has responded to feedback. Newer Patch Available Platform: Android Android applications.
Projects
None yet
Development

No branches or pull requests

3 participants