Skip to content
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

Closed
amarlette opened this issue Feb 3, 2021 · 6 comments · May be fixed by facebook/react-native-website#3438
Closed

Android: Modal announcements #30860

amarlette opened this issue Feb 3, 2021 · 6 comments · May be fixed by facebook/react-native-website#3438
Assignees
Labels
Accessibility Team - Evaluated Accessibility Needs: Docs Website PR To encourage the authors to create a website PR for documentation. Platform: Android Android applications.

Comments

@amarlette
Copy link

amarlette commented Feb 3, 2021

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:

)

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

@dulmandakh
Copy link
Contributor

Modal is just a container so you can build your own UI. Or you can use third-party ready made modals.

@amarlette
Copy link
Author

The intent of this issue is for React Native itself to perform these actions.

@amarlette amarlette reopened this Feb 11, 2021
@blavalla blavalla changed the title Android: Window change Android: Modal announcements Feb 24, 2021
@blavalla
Copy link
Contributor

blavalla commented Feb 24, 2021

@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?

@kacieb
Copy link
Contributor

kacieb commented Feb 24, 2021

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.

@blavalla
Copy link
Contributor

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.

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.
When one is set Talkback is also smart enough to know to announce this when the window first appears, and not to focus on it directly. It's not a property meant specifically for accessibility though, but there are implications if one isn't set, as Talkback will still read something when the Window appears, but since it's not something we define, the behavior may not be what a developer expects.

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.

@fabOnReact
Copy link
Contributor

@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

OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this issue May 22, 2023
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accessibility Team - Evaluated Accessibility Needs: Docs Website PR To encourage the authors to create a website PR for documentation. Platform: Android Android applications.
Projects
None yet
5 participants