question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android: Overriding default actions

See original GitHub issue

Description

Using the accessibilityActions prop you can override the default usage hints for the actions “activate” and “longpress” on Android by giving them a new label. While this works on most components, on <Button>, <Text>, <TextInput>, and <Picker> this has no effect.

React Native version:

v0.63

Expected Behavior

If the label for “activate” or “longpress” is overridden via the accessibilityActions prop, screen readers should announce the hint of “Double-tap to <your custom label>” or “Double-tap and hold to <your custom label>” rather than “Double-tap to activate” or “Double-tap and hold to longpress”.

Android Details

Since this properly works on most components, this is likely an issue on the Javascript side of these props simply not being passed along.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
blavallacommented, Mar 10, 2021

@huzaifaaak, on Android, React Native’s “accessibilityActions” API (which would include the accessibilityActions and onAccessibilityAction props) has three main purposes:

1.) To override the default “usage hint” label for the click or long-click actions, which is something Talkback allows you to do. 2.) To create a custom accessibility action, which can be triggered via Talkback’s actions menu. 3.) To change the behavior that occurs when a specific accessibility action (either custom, or a built-in one) is triggered.

To achieve #1, you’d only need to use the accessibilityActions prop, and add a label for either the “activate” or “longpress” actions. Setting a label here would change Talkback from saying “Double-tap to activate” to “Double-tap to <your custom label>”. This feature is what this issue is describing, and what currently doesn’t work on all components.

To create a fully custom action (#2), you’d need to give the action a name, a label, and then use the onAccessibilityAction prop to define behavior for that action. I am not sure if that is currently working for the listed problematic components, but my guess would be that it’s not, as I assume the entire accessibilityActions prop is simply not supported.

To support #3, I think you’d only need to implement the onAccessibilityAction prop, but you’d only be able to use it to override built-in actions such as activate, longpress on Android, or magicTap on iOS.

Feel free to investigate a bit to determine if use cased 2 and 3 are working not, I think a fix could be made at the same time as the fix to support overriding the usage hints, as they are likely connected problems. Let me know if you have any other questions!

2reactions
huzaifaaakcommented, Jun 13, 2021

@amarlette #31532 fixes this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to override default action bar with custom layout actionbar
I try to get rid of default action bar by load a custom action bar. But then, it become like this : enter...
Read more >
Android – Overriding the default Contextual Action Bar for text ...
I want to override the existing default Contextual Action Bar(CAB) for text selection. I mean, I want to display my own CAB, with...
Read more >
<activity> | Android Developers
The default value is " false ". This attribute is meaningful only for the root activity of a task; it's ignored for all...
Read more >
Activity | Android Developers
All of these are hooks that you can override to do appropriate work when the activity changes state. All activities will implement onCreate(Bundle)...
Read more >
Add an up action - Android Developers
You do not need to catch the up action in the activity's onOptionsItemSelected() method. Instead, that method should call its superclass, as ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found