Skip to content

Support "editable" on TextInput #476

Description

@thymikee

Describe the Feature

TextInput component from react-native has its own handling of being disabled/editable. It's not using responder system like Views, Texts and thus Touchables, so the logic we have already fails to catch it.

We should consider adding custom handling specific to native TextInput component, since it was working with @testing-library/react-native before v7.

Possible Implementations

Will likely involve detecting TextInput and verify if it's editable or not.

Test that fails with current implementation:

test('should not fire on disabled TextInput', () => {
  const handleChangeText = jest.fn();

  const screen = render(
    <TextInput onChangeText={handleChangeText} editable={false}>
      <Text>Trigger</Text>
    </TextInput>
  );

  fireEvent.changeText(screen.getByText('Trigger'), 'Trigger');
  expect(handleChangeText).not.toHaveBeenCalled();
});

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions