Skip to content

Commit 4d10dca

Browse files
authored
Blazor Web Template Accessibility (#51231)
# Blazor Web Template Accessibility ## Description 1. Make "Remember me" checkbox boarder darker ![darker-border-checkbox](https://github.com/dotnet/aspnetcore/assets/114938397/a5e99b3d-661e-4a18-9247-a3ce4ea3b7cf) 2. Show validation messages for Login page ![login-required-fields](https://github.com/dotnet/aspnetcore/assets/114938397/5205ebfc-11d9-468a-aa8e-3a5853c65ee4) 3. Add role="alert" to validation summaries in Login and Register pages so that narrator could announce the errors 4. Fix `aria-label` in QuickGrid Fixes #51127 Fixes #51153 Fixes #51156 ## Customer Impact 1. Low vision users will be able to see the checkbox control (color contrast ratio is more than 3:1) 2. Sighted users will have clear instructions that "Email" and "Password" fields are required. 3. Screen reader users will hear the narrator announcing the validation errors in Register and Login pages. 4. Screen reader users will hear the accessible names for buttons in QuickGrid.Paginator ## Regression? - [ ] Yes - [x] No [If yes, specify the version the behavior has regressed from] ## Risk - [ ] High - [ ] Medium - [x] Low [Justify the selection above] ## Verification - [x] Manual (required) - [ ] Automated ## Packaging changes reviewed? - [ ] Yes - [ ] No - [x] N/A ---- ## When servicing release/2.1 - [ ] Make necessary changes in eng/PatchConfig.props
1 parent cfc7ac6 commit 4d10dca

File tree

4 files changed

+12
-7
lines changed
  • src

4 files changed

+12
-7
lines changed

src/Components/QuickGrid/Microsoft.AspNetCore.Components.QuickGrid/src/Pagination/Paginator.razor

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
}
1616
</div>
1717
<nav role="navigation">
18-
<button class="go-first" type="button" @onclick="GoFirstAsync" disabled="@(!CanGoBack)" title="Go to first page" aria-title="Go to first page"></button>
19-
<button class="go-previous" type="button" @onclick="GoPreviousAsync" disabled="@(!CanGoBack)" title="Go to previous page" aria-title="Go to previous page"></button>
18+
<button class="go-first" type="button" @onclick="GoFirstAsync" disabled="@(!CanGoBack)" title="Go to first page" aria-label="Go to first page"></button>
19+
<button class="go-previous" type="button" @onclick="GoPreviousAsync" disabled="@(!CanGoBack)" title="Go to previous page" aria-label="Go to previous page"></button>
2020
<div class="pagination-text">
2121
Page <strong>@(State.CurrentPageIndex + 1)</strong>
2222
of <strong>@(State.LastPageIndex + 1)</strong>
2323
</div>
24-
<button class="go-next" type="button" @onclick="GoNextAsync" disabled="@(!CanGoForwards)" title="Go to next page" aria-title="Go to next page"></button>
25-
<button class="go-last" type="button" @onclick="GoLastAsync" disabled="@(!CanGoForwards)" title="Go to last page" aria-title="Go to last page"></button>
24+
<button class="go-next" type="button" @onclick="GoNextAsync" disabled="@(!CanGoForwards)" title="Go to next page" aria-label="Go to next page"></button>
25+
<button class="go-last" type="button" @onclick="GoLastAsync" disabled="@(!CanGoForwards)" title="Go to last page" aria-label="Go to last page"></button>
2626
</nav>
2727
}
2828
</div>

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Pages/Account/Login.razor

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
<section>
2222
<StatusMessage Message="@errorMessage" />
2323
<EditForm id="account" Model="Input" method="post" OnValidSubmit="LoginUser" FormName="login">
24+
<DataAnnotationsValidator />
2425
<h2>Use a local account to log in.</h2>
2526
<hr />
26-
<ValidationSummary class="text-danger" />
27+
<ValidationSummary class="text-danger" role="alert" />
2728
<div class="form-floating mb-3">
2829
<InputText id="email" @bind-Value="Input.Email" class="form-control" autocomplete="username" aria-required="true" placeholder="[email protected]" />
2930
<label for="email" class="form-label">Email</label>
@@ -36,7 +37,7 @@
3637
</div>
3738
<div class="checkbox mb-3">
3839
<label class="form-label">
39-
<InputCheckbox @bind-Value="Input.RememberMe" class="form-check-input" />
40+
<InputCheckbox @bind-Value="Input.RememberMe" class="darker-border-checkbox form-check-input" />
4041
Remember me
4142
</label>
4243
</div>

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Pages/Account/Register.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<DataAnnotationsValidator />
3030
<h2>Create a new account.</h2>
3131
<hr />
32-
<ValidationSummary class="text-danger" />
32+
<ValidationSummary class="text-danger" role="alert" />
3333
<div class="form-floating mb-3">
3434
<InputText id="email" @bind-Value="Input.Email" class="form-control" autocomplete="username" aria-required="true" placeholder="[email protected]" />
3535
<label for="email">Email</label>

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/wwwroot/app.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,7 @@ h1:focus {
4747
.blazor-error-boundary::after {
4848
content: "An error has occurred."
4949
}
50+
51+
.darker-border-checkbox.form-check-input {
52+
border-color: #929292;
53+
}

0 commit comments

Comments
 (0)