Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Libraries/Components/View/ReactNativeViewAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ReactNativeViewAttributes.UIView = {
onAccessibilityAction: true,
onAccessibilityTap: true,
onMagicTap: true,
onAccessibilityEscape: true,
collapsable: true,
needsOffscreenAlphaCompositing: true,
style: ReactNativeStyleAttributes,
Expand Down
8 changes: 8 additions & 0 deletions Libraries/Components/View/ViewPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ type DirectEventProps = $ReadOnly<{|
* See http://facebook.github.io/react-native/docs/view.html#onmagictap
*/
onMagicTap?: ?Function,

/**
* When `accessible` is `true`, the system will invoke this function when the
* user performs the escape gesture.
*
* See http://facebook.github.io/react-native/docs/view.html#onaccessibilityescape
*/
onAccessibilityEscape?: ?Function,
|}>;

type TouchEventProps = $ReadOnly<{|
Expand Down
5 changes: 5 additions & 0 deletions RNTester/js/AccessibilityIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class AccessibilityIOSExample extends React.Component<{}> {
<View onMagicTap={() => alert('onMagicTap success')} accessible={true}>
<Text>Accessibility magic tap example</Text>
</View>
<View
onAccessibilityEscape={() => alert('onAccessibilityEscape success')}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-alert: Unexpected alert.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what the expectation is here. this example code is consistent with the existing examples.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-alert: Unexpected alert.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no-alert: Unexpected alert.

accessible={true}>
<Text>Accessibility escape example</Text>
</View>
<View accessibilityLabel="Some announcement" accessible={true}>
<Text>Accessibility label example</Text>
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,12 @@ - (BOOL)accessibilityPerformMagicTap
return YES;
}

- (BOOL)accessibilityPerformEscape
{
_eventEmitter->onAccessibilityEscape();
return YES;
}

- (BOOL)didActivateAccessibilityCustomAction:(UIAccessibilityCustomAction *)action
{
_eventEmitter->onAccessibilityAction(RCTStringFromNSString(action.name));
Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTView.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
@property (nonatomic, copy) RCTDirectEventBlock onAccessibilityAction;
@property (nonatomic, copy) RCTDirectEventBlock onAccessibilityTap;
@property (nonatomic, copy) RCTDirectEventBlock onMagicTap;
@property (nonatomic, copy) RCTDirectEventBlock onAccessibilityEscape;

/**
* Accessibility properties
Expand Down
10 changes: 10 additions & 0 deletions React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ - (BOOL)accessibilityPerformMagicTap
}
}

- (BOOL)accessibilityPerformEscape
{
if (_onAccessibilityEscape) {
_onAccessibilityEscape(nil);
return YES;
} else {
return NO;
}
}

- (NSString *)description
{
NSString *superDescription = super.description;
Expand Down
1 change: 1 addition & 0 deletions React/Views/RCTViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ - (RCTShadowView *)shadowView
RCT_REMAP_VIEW_PROPERTY(onAccessibilityAction, reactAccessibilityElement.onAccessibilityAction, RCTDirectEventBlock)
RCT_REMAP_VIEW_PROPERTY(onAccessibilityTap, reactAccessibilityElement.onAccessibilityTap, RCTDirectEventBlock)
RCT_REMAP_VIEW_PROPERTY(onMagicTap, reactAccessibilityElement.onMagicTap, RCTDirectEventBlock)
RCT_REMAP_VIEW_PROPERTY(onAccessibilityEscape, reactAccessibilityElement.onAccessibilityEscape, RCTDirectEventBlock)
RCT_REMAP_VIEW_PROPERTY(testID, reactAccessibilityElement.accessibilityIdentifier, NSString)

RCT_EXPORT_VIEW_PROPERTY(backgroundColor, UIColor)
Expand Down
4 changes: 4 additions & 0 deletions ReactCommon/fabric/components/view/ViewEventEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ void ViewEventEmitter::onAccessibilityMagicTap() const {
dispatchEvent("magicTap");
}

void ViewEventEmitter::onAccessibilityEscape() const {
dispatchEvent("accessibilityEscape");
}

#pragma mark - Layout

void ViewEventEmitter::onLayout(const LayoutMetrics &layoutMetrics) const {
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/fabric/components/view/ViewEventEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class ViewEventEmitter : public TouchEventEmitter {
void onAccessibilityAction(const std::string &name) const;
void onAccessibilityTap() const;
void onAccessibilityMagicTap() const;
void onAccessibilityEscape() const;

#pragma mark - Layout

Expand Down