Skip to content

Commit e19d9de

Browse files
franticfacebook-github-bot
authored andcommitted
Make testID work for iOS tabs
Reviewed By: shergin Differential Revision: D6455054 fbshipit-source-id: 3c667b585e9332a1dbfff1fd3325f2c95985a5be
1 parent ca10604 commit e19d9de

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

React/Views/RCTTabBarItem.h

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
@property (nonatomic, assign, getter=isSelected) BOOL selected;
2929
@property (nonatomic, readonly) UITabBarItem *barItem;
3030
@property (nonatomic, copy) RCTBubblingEventBlock onPress;
31+
@property (nonatomic, strong) NSString *testID;
3132

3233
#if TARGET_OS_TV
3334
@property (nonatomic, assign) BOOL wasSelectedInJS;

React/Views/RCTTabBarItem.m

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ - (UITabBarItem *)barItem
5858
return _barItem;
5959
}
6060

61+
- (void)setTestID:(NSString *)testID
62+
{
63+
self.barItem.accessibilityIdentifier = testID;
64+
}
65+
6166
- (void)setBadge:(id)badge
6267
{
6368
_badge = [badge copy];

React/Views/RCTTabBarItemManager.m

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ - (UIView *)view
3030
RCT_EXPORT_VIEW_PROPERTY(onPress, RCTBubblingEventBlock)
3131
RCT_EXPORT_VIEW_PROPERTY(badgeColor, UIColor)
3232
RCT_EXPORT_VIEW_PROPERTY(isTVSelectable, BOOL)
33+
RCT_EXPORT_VIEW_PROPERTY(testID, NSString)
3334
RCT_CUSTOM_VIEW_PROPERTY(title, NSString, RCTTabBarItem)
3435
{
3536
view.barItem.title = json ? [RCTConvert NSString:json] : defaultView.barItem.title;

0 commit comments

Comments
 (0)