Skip to content

Commit fb7a0a3

Browse files
authored
include Pressable Component on Touchable (#103)
1 parent f13f31b commit fb7a0a3

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

__tests__/src/rules/no-nested-touchables-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,14 @@ ruleTester.run('no-nested-touchables', rule, {
7373
><TouchableOpacity><Text>Nested</Text></TouchableOpacity></TouchableOpacity>`,
7474
errors: [expectedError],
7575
},
76+
{
77+
code: `<TouchableOpacity
78+
accessibilityTraits="button"
79+
accessibilityComponentType="button"
80+
accessibilityLabel="Tap Me!"
81+
accessible={true}
82+
><Pressable><Text>Nested</Text></Pressable></TouchableOpacity>`,
83+
errors: [expectedError],
84+
},
7685
].map(parserOptionsMapper),
7786
});

docs/rules/no-nested-touchables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# no-nested-touchables
22

3-
<Touchable*> or <Button /> will not work inside an accessible element. Any element that has the accessible={true} property (along with the accessibleLabel property) must therefore not contain any <Touchable*> or <Button /> elements.
3+
<Touchable*> and <Pressable /> or <Button /> will not work inside an accessible element. Any element that has the accessible={true} property (along with the accessibleLabel property) must therefore not contain any <Touchable*> and <Pressable /> or <Button /> elements.
44

55
### References
66

src/util/isTouchable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const defaultTouchables = {
1515
TouchableWithoutFeedback: true,
1616
TouchableNativeFeedback: true,
1717
TouchableBounce: true,
18+
Pressable: true,
1819
};
1920

2021
export default function isTouchable(

0 commit comments

Comments
 (0)