Skip to content

Commit 04125cc

Browse files
suezzothymikee
authored andcommitted
feat: add pointerEvents handling
1 parent e018da5 commit 04125cc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/fireEvent.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,25 @@ const isTouchResponder = (element?: ReactTestInstance) => {
1717
return !!element?.props.onStartShouldSetResponder || isTextInput(element);
1818
};
1919

20+
const isPointerEventEnabled = (element?: ReactTestInstance) => {
21+
if (
22+
element?.props.pointerEvents === 'none' ||
23+
element?.props.pointerEvents === 'box-only'
24+
) {
25+
return false;
26+
}
27+
28+
if (!element?.parent) return true;
29+
30+
return isPointerEventEnabled(element.parent);
31+
};
32+
2033
const isEventEnabled = (
2134
element?: ReactTestInstance,
2235
touchResponder?: ReactTestInstance
2336
) => {
2437
if (isTextInput(element)) return element?.props.editable !== false;
38+
if (!isPointerEventEnabled(element)) return false;
2539

2640
const touchStart = touchResponder?.props.onStartShouldSetResponder?.();
2741
const touchMove = touchResponder?.props.onMoveShouldSetResponder?.();

0 commit comments

Comments
 (0)