添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

ScrollView doesn't scroll to focused element #28509

@Zahoq

Description

@Zahoq

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

  • 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