Skip to content

On Android, TextInputs within a position: absolute view that's inside another view with onLayout can't be focused #29308

Description

@hsource

Please provide all the information requested. Issues that do not follow this format are likely to stall.

Description

Given a hierarchy of views:

  1. <View> with onLayout prop
  2. <View> that has position: 'absolute' style
  3. A TextInput

Text inside the TextInput can't be selected. Removing the first view's onLayout prop or the second view's position: 'absolute' will allow text in the TextInput to be selected.

React Native version:

v0.62.2

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Render inside a component the following:
import * as React from 'react';
import { TextInput, View, Text } from 'react-native';

export default function App() {
  return (
    <View style={{ flex: 1 }}>
      {
        // Remove the onLayout for the text to become selectable
      }
      <View onLayout={() => {}}>
        <View
          style={{
            position: 'absolute',
            width: '100%',
            top: 50,
            paddingHorizontal: 8,
          }}
        >
          <Text style={{ marginBottom: 10 }} wrap>
            The following text should be selectable. For some reason, it's not
            selectable on Android when placed inside the original
            KeyboardAvoidingView or any View with an onLayout callback.
          </Text>
          <TextInput defaultValue="Try selecting this text" />
        </View>
      </View>
    </View>
  );
}
  1. On Android, try to select text inside the TextInput

Expected Results

Describe what you expected to happen.

The text should be selected

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

https://snack.expo.io/@harrytravelchime/react-native-issue-29308

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: TextInputRelated to the TextInput component.Component: ViewPlatform: AndroidAndroid applications.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions