mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
fix(android): NavigationButton was read as "Button" by screenreaders. (#5949)
The navigation button for the vision-impaired users were always read as: "Button" by the TalkBack service on Android.
This commit is contained in:

committed by
Alexander Vakrilov

parent
b0afd3ab30
commit
0e04cb4ad1
@ -32,6 +32,19 @@ export function test_navigationButton_visibility() {
|
||||
TKUnit.assertNull(toolbar.getNavigationIcon(), "Visibility does not work");
|
||||
}
|
||||
|
||||
export function test_navigationButton_contentDecription() {
|
||||
const actionItem = new ActionItem();
|
||||
actionItem.icon = "~/small-image.png";
|
||||
const actionItemText = "NavButton with small-image";
|
||||
actionItem.text = actionItemText;
|
||||
const page = actionTestsCommon.createPageAndNavigate();
|
||||
page.actionBar.navigationButton = actionItem;
|
||||
|
||||
const toolbar = <android.support.v7.widget.Toolbar>page.actionBar.nativeViewProtected;
|
||||
|
||||
TKUnit.assertEqual(toolbar.getNavigationContentDescription(), actionItemText, "Navigation Button should have an content decription");
|
||||
}
|
||||
|
||||
export function test_set_actionView_to_attached_actionItem_propagates_context() {
|
||||
const actionItem = new ActionItem();
|
||||
const actionButton = new Button();
|
||||
|
@ -223,6 +223,9 @@ export class ActionBar extends ActionBarBase {
|
||||
this.nativeViewProtected.setNavigationIcon(drawableOrId);
|
||||
}
|
||||
|
||||
// Set navigation content descripion, used by screen readers for the vision-impaired users
|
||||
this.nativeViewProtected.setNavigationContentDescription(navButton.text || null);
|
||||
|
||||
let navBtn = new WeakRef(navButton);
|
||||
this.nativeViewProtected.setNavigationOnClickListener(new android.view.View.OnClickListener({
|
||||
onClick: function (v) {
|
||||
|
Reference in New Issue
Block a user