-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android: Modal announcements #30860
Android: Modal announcements #30860
Comments
Modal is just a container so you can build your own UI. Or you can use third-party ready made modals. |
The intent of this issue is for React Native itself to perform these actions. |
@kacieb, @lunaleaps, @nadiia, do we want RN's dialog to have a way to visibly display a title as well as have one set for accessibility? Right now, it relies on a user passing content into it that will act as a title, but this content is not technically considered a "title" by Android at an OS level, which leads to this problem. We can set a title only for accessibility, or we could have the option to set a title both visibly and for accessibility. Thoughts? |
Just wanted to check - it sounds like "title" is different from "accessibilityLabel" (or contentDescription on Android)? It seems reasonable to me to add a new prop to Modal to allow people to pass in a title for accessibility purposes. This would require both Android and iOS work. I think this component is generic enough that we don't want to render the title for them, though (since you can put anything you want in this modal) - the prop should only be for accessibility. We should be very descriptive about when to use it in our documentation about the prop. The only issue I see with adding a prop only for accessibility is it wouldn't move the focus correctly to the first "non-title" element. This component could honestly also use a revamp in general, I noticed quite a few deprecated lifecycle methods when looking at it, (and there may be better solutions elsewhere in open source), so I don't think this issue is high priority. |
Yeah, on Android a Window (which a dialog is) doesn't have the normal View properties like contentDescription, etc. A title is meant to be visibly displayed at the top of the Window and used to let the user know what the purpose of this window is. As a fun aside, the same general rule applies to activities on Android, which can also have titles set, but if you don't set them, it will just read your apps name instead of trying to find a title in the content. If you've used the an app and heard Talkback say the app name over and over whenever you open some new screen, it probably means you forgot to add an activity title. |
@blavalla I included an API Proposal in the Draft PR #34969 Thanks Video of the Functionality on Android https://www.icloud.com/iclouddrive/0fdBl7MCKgQ3d0vMeRR-DDVuA#modal_title_android |
…vent (facebook#34969) Summary: - Adds `AccessibilityEvent.TYPE_VIEW_HOVER_ENTER` to AccessibilityNodeInfo sendAccessibilityEvent - Adds an example implementation. fixes facebook#30860 fixes facebook#30097 Related Documentation facebook/react-native-website#3438 ## Changelog [Android] [Added] - Add TYPE_VIEW_HOVER_ENTER to AccessibilityNodeInfo sendAccessibilityEvent Pull Request resolved: facebook#34969 Test Plan: Android: facebook#34969 (comment) facebook#34969 (comment) iOS: facebook#34969 (comment) facebook#34969 (comment) Reviewed By: christophpurrer Differential Revision: D42613990 Pulled By: lunaleaps fbshipit-source-id: 8c8950610799dcc74067d2b47b44d4ff030f66e5
Requires API Proposal
This issue may require a new API, or a change to an existing 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
On Android, when new Windows appear, their title is announced. If no title is set, it will treat the first visible item as a title, and instead announce it, moving focus automatically to the second element. This is not always desired, so we should provide a way to set a specific title to be announced instead.
This issue specifically applies to the component (https://reactnative.dev/docs/modal), which does not have a way to specify a title. Other Window types, such as Alert's, work correctly as their only content is treated as the title.
React Native version:
v0.63
Expected Behavior
Upon appearance, 's should announce a specified title, and focus should move into them, landing on the first visible element. If no title is specified, the existing behavior should apply, which treats the first visible element as the title, with focus moving to the second visible element.
Android Details
In Android Windows such as "Dialog" have the ability to set a title via a "setTitle()" method (https://developer.android.com/reference/android/app/Dialog#setTitle(java.lang.CharSequence)).
In React Native, when we create a new Dialog for the component, we do not set this title (RN source here:
react-native/ReactAndroid/src/main/java/com/facebook/react/views/modal/ReactModalHostView.java
Line 265 in 5348a98
We need to set this title for the accessibility system to pick it up.
If you want the title to only be picked up by the accessibility system, but not visible displayed, you only need to set the title on the Window attributes, which you should be able to do by calling
dialog.getWindow().getAttributes().setTitle("my title")
. This is exactly what happens when you call setTitle() on the Dialog itself in the Android source.Android source here: https://cs.android.com/android/platform/superproject/+/master:frameworks/base/core/java/android/app/Dialog.java;l=611
The text was updated successfully, but these errors were encountered: