facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
119.04k stars 24.32k forks source link

iOS: Allow direct interaction #30856

Open amarlette opened 3 years ago

amarlette commented 3 years ago

Requires API Proposal

This issue requires a new API. An API proposal should be added and discussed before proceeding with implementation. The API proposal can be added in the comments of this issue or linked as a separate issue.

Description

There is no way to specify a component to allow direct interaction when using VoiceOver. Components that allow direct interaction will pass through the standard touch events to the component, rather than having these events be intercepted by VoiceOver to trigger its various interaction gestures. This is useful if you are building things such as drawing interfaces which would not properly work with VoiceOvers gesture controls.

React Native version:

v0.63

Expected Behavior

An API would need to be added that would allow for this feature. When this is enabled, touches on the component should act as standard touch events as if a user did not have VoiceOver enabled.

iOS Details

This API should map directly to iOS's allowsDirectInteraction trait. This should probably not exist as a "role" in RN, even though that is where most other traits live, since there is no Android equivalent. Having this as a separate iOS-only prop makes it clear that this feature is specific to that platform.

frastlin commented 1 year ago

Any progress on this issue? We have a project that needs allowsDirectInteraction on iOS. We are evaluating React Native and if it doesn't have this function we'll look somewhere else. According to the accessibility docs, this feature is not implemented yet.

github-actions[bot] commented 6 months ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

frastlin commented 6 months ago

Apparently adding accessibilityTraits=["allowsDirectInteraction"] to an element should work, I will be trying it shortly. https://s-pace.github.io/react-native/docs/accessibility.html

frastlin commented 6 months ago

Update: accessibilityTraits=["allowsDirectInteraction"] was removed in the 0.57 release and was not replaced with anything: https://reactnative.dev/blog/2018/08/13/react-native-accessibility-updates Another element should be added to the accessibilityRole called "allowsDirectInteraction". This would solve the problem. This is a very important feature for our team, please let me know what I can do to get this regression fixed.

zibs commented 4 months ago

One can still use accessibilityRole="allowsDirectInteraction" even thought TS complains as https://github.com/facebook/react-native/blob/d8739e1d37ceebb9643ca56d66a54aaca330665a/packages/react-native/React/Views/RCTViewManager.m#L33 still has it available.