Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Android] Fix TalkBack to read back button title when it is set #13563

Merged
merged 5 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;

#if UITEST
using Xamarin.Forms.Core.UITests;
using Xamarin.UITest;
using NUnit.Framework;
#endif

namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[Category(UITestCategories.ManualReview)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 8701, "TalkBack reads labeled back button as 'Unlabeled button'", PlatformAffected.Android)]
public class Issue8701 : TestNavigationPage
{
protected override void Init()
{
Navigation.PushAsync(new Issue8701FirstPage());
}

class Issue8701FirstPage : ContentPage
{
public Issue8701FirstPage()
{
Title = "Issue 8701 first page";
SetBackButtonTitle(this, "Back button title is set");

Button button = new Button() { Text = "Navigate to the second page" };
button.Clicked += async (sender, args) => await Navigation.PushAsync(new Issue8701SecondPage());

Content = new StackLayout()
{
Margin = 20,

Children =
{
button
}
};

}
}

class Issue8701SecondPage : ContentPage
{
public Issue8701SecondPage()
{
Title = "Issue 8701 second page";

Label label = new Label() { Text = "Enable TalkBack and tap on the back button. Test passes if TalkBack reads: 'Back button title is set'" };

Content = new StackLayout()
{
Margin = 20,

Children =
{
label
}
};
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1711,6 +1711,7 @@
<Compile Include="$(MSBuildThisFileDirectory)ShellFlyoutContentOffest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ShellFlyoutContentWithZeroMargin.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13436.xaml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue8701.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue13390.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,10 @@ void UpdateToolbar()
bar.NavigationIcon = icon;

var prevPage = Element.Peek(1);
_defaultNavigationContentDescription = bar.SetNavigationContentDescription(prevPage, _defaultNavigationContentDescription);
var backButtonTitle = NavigationPage.GetBackButtonTitle(prevPage);
_defaultNavigationContentDescription = backButtonTitle != null
? bar.SetNavigationContentDescription(prevPage, backButtonTitle)
: bar.SetNavigationContentDescription(prevPage, _defaultNavigationContentDescription);
}
else if (toggle != null && _flyoutPage != null)
{
Expand Down