Skip to content

Commit 95b397a

Browse files
committed
feat: use editable prop to check for event handling
1 parent d8a47f2 commit 95b397a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/fireEvent.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
import act from './act';
33
import { ErrorWithStack } from './helpers/errors';
44

5+
const isTextInputComponent = (element: ReactTestInstance) => {
6+
// eslint-disable-next-line import/no-extraneous-dependencies
7+
const { TextInput } = require('react-native');
8+
return element.type === TextInput;
9+
};
10+
511
const findEventHandler = (
612
element: ReactTestInstance,
713
eventName: string,
@@ -14,8 +20,11 @@ const findEventHandler = (
1420

1521
const isHostComponent = typeof element.type === 'string';
1622
const hostElement = isHostComponent ? element : nearestHostDescendent;
17-
const isEventEnabled =
18-
hostElement?.props.onStartShouldSetResponder?.() !== false;
23+
24+
const isEventEnabled = isTextInputComponent(element)
25+
? element.props.editable !== false
26+
: hostElement?.props.onStartShouldSetResponder?.() !== false;
27+
1928
if (handler && isEventEnabled) return handler;
2029

2130
// Do not bubble event to the root element

0 commit comments

Comments
 (0)