Skip to content

Commit 656d81c

Browse files
authored
Set aria-current for manage pages (#37274)
1 parent 6e92e94 commit 656d81c

File tree

5 files changed

+150
-16
lines changed

5 files changed

+150
-16
lines changed

src/Identity/UI/src/Areas/Identity/Pages/V4/Account/Manage/ManageNavPages.cs

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
54
using Microsoft.AspNetCore.Mvc.Rendering;
65

76
namespace Microsoft.AspNetCore.Identity.UI.V4.Pages.Account.Manage.Internal
@@ -115,8 +114,67 @@ public static class ManageNavPages
115114
public static string PageNavClass(ViewContext viewContext, string page)
116115
{
117116
var activePage = viewContext.ViewData["ActivePage"] as string
118-
?? System.IO.Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName);
117+
?? Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName);
119118
return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null;
120119
}
120+
121+
/// <summary>
122+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
123+
/// directly from your code. This API may change or be removed in future releases.
124+
/// </summary>
125+
public static string IndexAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, Index);
126+
127+
/// <summary>
128+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
129+
/// directly from your code. This API may change or be removed in future releases.
130+
/// </summary>
131+
public static string EmailAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, Email);
132+
133+
/// <summary>
134+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
135+
/// directly from your code. This API may change or be removed in future releases.
136+
/// </summary>
137+
public static string ChangePasswordAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, ChangePassword);
138+
139+
/// <summary>
140+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
141+
/// directly from your code. This API may change or be removed in future releases.
142+
/// </summary>
143+
public static string DownloadPersonalDataAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, DownloadPersonalData);
144+
145+
/// <summary>
146+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
147+
/// directly from your code. This API may change or be removed in future releases.
148+
/// </summary>
149+
public static string DeletePersonalDataAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, DeletePersonalData);
150+
151+
/// <summary>
152+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
153+
/// directly from your code. This API may change or be removed in future releases.
154+
/// </summary>
155+
public static string ExternalLoginsAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, ExternalLogins);
156+
157+
/// <summary>
158+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
159+
/// directly from your code. This API may change or be removed in future releases.
160+
/// </summary>
161+
public static string PersonalDataAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, PersonalData);
162+
163+
/// <summary>
164+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
165+
/// directly from your code. This API may change or be removed in future releases.
166+
/// </summary>
167+
public static string TwoFactorAuthenticationAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, TwoFactorAuthentication);
168+
169+
/// <summary>
170+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
171+
/// directly from your code. This API may change or be removed in future releases.
172+
/// </summary>
173+
public static string AriaCurrent(ViewContext viewContext, string page)
174+
{
175+
var activePage = viewContext.ViewData["ActivePage"] as string
176+
?? Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName);
177+
return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "page" : null;
178+
}
121179
}
122180
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<ul class="nav nav-pills flex-column">
2-
<li class="nav-item"><a class="nav-link @ManageNavPages.IndexNavClass(ViewContext)" id="profile" asp-page="./Index">Profile</a></li>
3-
<li class="nav-item"><a class="nav-link @ManageNavPages.EmailNavClass(ViewContext)" id="email" asp-page="./Email">Email</a></li>
4-
<li class="nav-item"><a class="nav-link @ManageNavPages.ChangePasswordNavClass(ViewContext)" id="change-password" asp-page="./ChangePassword">Password</a></li>
2+
<li class="nav-item"><a class="nav-link @ManageNavPages.IndexNavClass(ViewContext)" id="profile" asp-page="./Index" aria-current="@ManageNavPages.IndexAriaCurrent(ViewContext)">Profile</a></li>
3+
<li class="nav-item"><a class="nav-link @ManageNavPages.EmailNavClass(ViewContext)" id="email" asp-page="./Email" aria-current="@ManageNavPages.EmailAriaCurrent(ViewContext)">Email</a></li>
4+
<li class="nav-item"><a class="nav-link @ManageNavPages.ChangePasswordNavClass(ViewContext)" id="change-password" asp-page="./ChangePassword" aria-current="@ManageNavPages.ChangePasswordAriaCurrent(ViewContext)">Password</a></li>
55
@if ((bool)(ViewData["ManageNav.HasExternalLogins"] ?? false))
66
{
7-
<li id="external-logins" class="nav-item"><a id="external-login" class="nav-link @ManageNavPages.ExternalLoginsNavClass(ViewContext)" asp-page="./ExternalLogins">External logins</a></li>
7+
<li id="external-logins" class="nav-item"><a id="external-login" class="nav-link @ManageNavPages.ExternalLoginsNavClass(ViewContext)" asp-page="./ExternalLogins" aria-current="@ManageNavPages.ExternalLoginsAriaCurrent(ViewContext)">External logins</a></li>
88
}
9-
<li class="nav-item"><a class="nav-link @ManageNavPages.TwoFactorAuthenticationNavClass(ViewContext)" id="two-factor" asp-page="./TwoFactorAuthentication">Two-factor authentication</a></li>
10-
<li class="nav-item"><a class="nav-link @ManageNavPages.PersonalDataNavClass(ViewContext)" id="personal-data" asp-page="./PersonalData">Personal data</a></li>
9+
<li class="nav-item"><a class="nav-link @ManageNavPages.TwoFactorAuthenticationNavClass(ViewContext)" id="two-factor" asp-page="./TwoFactorAuthentication" aria-current="@ManageNavPages.TwoFactorAuthenticationAriaCurrent(ViewContext)">Two-factor authentication</a></li>
10+
<li class="nav-item"><a class="nav-link @ManageNavPages.PersonalDataNavClass(ViewContext)" id="personal-data" asp-page="./PersonalData" aria-current="@ManageNavPages.PersonalDataAriaCurrent(ViewContext)">Personal data</a></li>
1111
</ul>

src/Identity/UI/src/Areas/Identity/Pages/V5/Account/Manage/ManageNavPages.cs

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System;
54
using Microsoft.AspNetCore.Mvc.Rendering;
65

76
namespace Microsoft.AspNetCore.Identity.UI.V5.Pages.Account.Manage.Internal
@@ -115,8 +114,67 @@ public static class ManageNavPages
115114
public static string PageNavClass(ViewContext viewContext, string page)
116115
{
117116
var activePage = viewContext.ViewData["ActivePage"] as string
118-
?? System.IO.Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName);
117+
?? Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName);
119118
return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "active" : null;
120119
}
120+
121+
/// <summary>
122+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
123+
/// directly from your code. This API may change or be removed in future releases.
124+
/// </summary>
125+
public static string IndexAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, Index);
126+
127+
/// <summary>
128+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
129+
/// directly from your code. This API may change or be removed in future releases.
130+
/// </summary>
131+
public static string EmailAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, Email);
132+
133+
/// <summary>
134+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
135+
/// directly from your code. This API may change or be removed in future releases.
136+
/// </summary>
137+
public static string ChangePasswordAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, ChangePassword);
138+
139+
/// <summary>
140+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
141+
/// directly from your code. This API may change or be removed in future releases.
142+
/// </summary>
143+
public static string DownloadPersonalDataAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, DownloadPersonalData);
144+
145+
/// <summary>
146+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
147+
/// directly from your code. This API may change or be removed in future releases.
148+
/// </summary>
149+
public static string DeletePersonalDataAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, DeletePersonalData);
150+
151+
/// <summary>
152+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
153+
/// directly from your code. This API may change or be removed in future releases.
154+
/// </summary>
155+
public static string ExternalLoginsAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, ExternalLogins);
156+
157+
/// <summary>
158+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
159+
/// directly from your code. This API may change or be removed in future releases.
160+
/// </summary>
161+
public static string PersonalDataAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, PersonalData);
162+
163+
/// <summary>
164+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
165+
/// directly from your code. This API may change or be removed in future releases.
166+
/// </summary>
167+
public static string TwoFactorAuthenticationAriaCurrent(ViewContext viewContext) => AriaCurrent(viewContext, TwoFactorAuthentication);
168+
169+
/// <summary>
170+
/// This API supports the ASP.NET Core Identity default UI infrastructure and is not intended to be used
171+
/// directly from your code. This API may change or be removed in future releases.
172+
/// </summary>
173+
public static string AriaCurrent(ViewContext viewContext, string page)
174+
{
175+
var activePage = viewContext.ViewData["ActivePage"] as string
176+
?? Path.GetFileNameWithoutExtension(viewContext.ActionDescriptor.DisplayName);
177+
return string.Equals(activePage, page, StringComparison.OrdinalIgnoreCase) ? "page" : null;
178+
}
121179
}
122180
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<ul class="nav nav-pills flex-column">
2-
<li class="nav-item"><a class="nav-link @ManageNavPages.IndexNavClass(ViewContext)" id="profile" asp-page="./Index">Profile</a></li>
3-
<li class="nav-item"><a class="nav-link @ManageNavPages.EmailNavClass(ViewContext)" id="email" asp-page="./Email">Email</a></li>
4-
<li class="nav-item"><a class="nav-link @ManageNavPages.ChangePasswordNavClass(ViewContext)" id="change-password" asp-page="./ChangePassword">Password</a></li>
2+
<li class="nav-item"><a class="nav-link @ManageNavPages.IndexNavClass(ViewContext)" id="profile" asp-page="./Index" aria-current="@ManageNavPages.IndexAriaCurrent(ViewContext)">Profile</a></li>
3+
<li class="nav-item"><a class="nav-link @ManageNavPages.EmailNavClass(ViewContext)" id="email" asp-page="./Email" aria-current="@ManageNavPages.EmailAriaCurrent(ViewContext)">Email</a></li>
4+
<li class="nav-item"><a class="nav-link @ManageNavPages.ChangePasswordNavClass(ViewContext)" id="change-password" asp-page="./ChangePassword" aria-current="@ManageNavPages.ChangePasswordAriaCurrent(ViewContext)">Password</a></li>
55
@if ((bool)(ViewData["ManageNav.HasExternalLogins"] ?? false))
66
{
7-
<li id="external-logins" class="nav-item"><a id="external-login" class="nav-link @ManageNavPages.ExternalLoginsNavClass(ViewContext)" asp-page="./ExternalLogins">External logins</a></li>
7+
<li id="external-logins" class="nav-item"><a id="external-login" class="nav-link @ManageNavPages.ExternalLoginsNavClass(ViewContext)" asp-page="./ExternalLogins" aria-current="@ManageNavPages.ExternalLoginsAriaCurrent(ViewContext)">External logins</a></li>
88
}
9-
<li class="nav-item"><a class="nav-link @ManageNavPages.TwoFactorAuthenticationNavClass(ViewContext)" id="two-factor" asp-page="./TwoFactorAuthentication">Two-factor authentication</a></li>
10-
<li class="nav-item"><a class="nav-link @ManageNavPages.PersonalDataNavClass(ViewContext)" id="personal-data" asp-page="./PersonalData">Personal data</a></li>
9+
<li class="nav-item"><a class="nav-link @ManageNavPages.TwoFactorAuthenticationNavClass(ViewContext)" id="two-factor" asp-page="./TwoFactorAuthentication" aria-current="@ManageNavPages.TwoFactorAuthenticationAriaCurrent(ViewContext)">Two-factor authentication</a></li>
10+
<li class="nav-item"><a class="nav-link @ManageNavPages.PersonalDataNavClass(ViewContext)" id="personal-data" asp-page="./PersonalData" aria-current="@ManageNavPages.PersonalDataAriaCurrent(ViewContext)">Personal data</a></li>
1111
</ul>

0 commit comments

Comments
 (0)