Skip to content

Commit

Permalink
Extend AccessibilityInfo.sendAccessibilityEvent to support 'click' ev…
Browse files Browse the repository at this point in the history
…ent for Android

Summary:
This diff extends AccessibilityInfo.sendAccessibilityEvent to support 'click' event on RN Android

changelog: [internal] internal

Reviewed By: kacieb

Differential Revision: D27060395

fbshipit-source-id: 5bf7479d72efb66c3a388fc3ea11990e285ca054
  • Loading branch information
mdvacca authored and facebook-github-bot committed Mar 20, 2021
1 parent 3f57120 commit eacc940
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type AccessibilityEventDefinitions = {
change: [boolean],
};

type AccessibilityEventTypes = 'focus';
type AccessibilityEventTypes = 'focus' | 'click';

const _subscriptions = new Map();

Expand Down Expand Up @@ -162,7 +162,12 @@ const AccessibilityInfo = {
eventType: AccessibilityEventTypes,
) {
// route through React renderer to distinguish between Fabric and non-Fabric handles
sendAccessibilityEvent(handle, eventType);
// iOS only supports 'focus' event types
if (eventType === 'focus') {
sendAccessibilityEvent(handle, eventType);
} else if (eventType === 'click') {
// Do nothing!
}
},

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ type AccessibilityEventDefinitions = {
],
};

type AccessibilityEventTypes = 'focus';
// 'click' event type is not implemented in iOS. It's declared here to avoid flow type errors
type AccessibilityEventTypes = 'focus' | 'click';

const _subscriptions = new Map();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ function legacySendAccessibilityEvent(
UIManager.getConstants().AccessibilityEventTypes.typeViewFocused,
);
}
if (eventType === 'click') {
UIManager.sendAccessibilityEvent(
reactTag,
UIManager.getConstants().AccessibilityEventTypes.typeViewClicked,
);
}
}

module.exports = legacySendAccessibilityEvent;

0 comments on commit eacc940

Please sign in to comment.