Skip to content

Commit cfe8188

Browse files
committed
Add KeyboardNavigation & Aria Labels
1 parent 7375199 commit cfe8188

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

CodeBeam.MudBlazor.Extensions/Components/StepperExtended/MudStepExtended.razor.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ private bool ShouldBeHidden()
143143
if (showingResult || showingIntro)
144144
return true;
145145

146-
// Normal step görünürlüğü
147146
bool isActive = MudStepperExtended.ActiveIndex < MudStepperExtended.Steps.Count &&
148147
MudStepperExtended.Steps[MudStepperExtended.ActiveIndex] == this;
149148

CodeBeam.MudBlazor.Extensions/Components/StepperExtended/MudStepperExtended.razor

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<CascadingValue Value="this" IsFixed="true">
1111
<MudStack Class="@Classname" Style="@Style">
1212
<MudStack Class="mud-stepper-header-content-wrapper-extended" Row="@Vertical">
13-
<div class="mud-stepper-inner-header-extended [email protected] @(Vertical ? "vertical" : "horizontal")">
13+
<div class="mud-stepper-inner-header-extended [email protected] @(Vertical ? "vertical" : "horizontal")" role="list">
1414
<div class="@(Vertical ? "mud-stepper-sub-inner-header-vertical-extended" : "mud-stepper-sub-inner-header-extended")">
1515
@{
1616
MudStepExtended? currentStep = null;
@@ -27,7 +27,7 @@
2727
}
2828

2929
<div class="mud-stepper-step [email protected] @(Vertical ? "vertical" : "horizontal") @(Vertical ? "d-flex" : "")">
30-
<div @onclick="@(Linear ? null! : () => GoToStepByReferenceAsync(step))" class="@HeaderClassname">
30+
<div @onclick="@(Linear ? null! : () => GoToStepByReferenceAsync(step))" class="@HeaderClassname" role="button" tabindex="@(Linear ? -1 : 0)" @onkeydown="(args) => HandleHeaderKeyDown(args, step)">
3131
@{
3232
bool active = IsStepActive(step);
3333
}
@@ -77,8 +77,8 @@
7777
{
7878
<MudText Class="@(Vertical ? "mud-stepper-text-mobile-vertical-extended" : "mud-stepper-text-mobile-extended")" Typo="Typo.body2" Color="@Color">@GetMobileStepPositionText()</MudText>
7979
}
80-
<MudProgressLinear Class="@ProgressClassname" Vertical="@Vertical" Color="@Color" Value="@ProgressValue" Min="0" Max="100" />
81-
80+
<MudProgressLinear Class="@ProgressClassname" Vertical="@Vertical" Color="@Color" Value="@ProgressValue" Min="0" Max="100"
81+
role="progressbar" aria-valuenow="@ProgressValue" aria-valuemin="0" aria-valuemax="100" />
8282
</div>
8383
@if (Loading)
8484
{

CodeBeam.MudBlazor.Extensions/Components/StepperExtended/MudStepperExtended.razor.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Microsoft.AspNetCore.Components;
33
using MudBlazor;
44
using MudBlazor.Utilities;
5+
using Microsoft.AspNetCore.Components.Web;
56

67
namespace MudExtensions
78
{
@@ -282,7 +283,7 @@ protected void UpdateProgressValue()
282283
/// </summary>
283284
[Parameter]
284285
public Variant Variant { get; set; }
285-
286+
286287
/// <summary>
287288
/// Choose header badge view. Default is all.
288289
/// </summary>
@@ -340,7 +341,7 @@ protected void UpdateProgressValue()
340341
/// </summary>
341342
[Parameter]
342343
public Func<StepChangeDirection, int, Task<bool>>? PreventStepChangeAsync { get; set; }
343-
344+
344345
/// <summary>
345346
/// Gets or sets a delegate that is invoked asynchronously before the finishing action occurs. The delegate
346347
/// should return a task that resolves to <see langword="true"/> to allow the action to proceed, or <see
@@ -1017,7 +1018,7 @@ public void ForceRender()
10171018
/// disabled.</param>
10181019
protected void OnBreakpointChanged(Breakpoint breakpoint)
10191020
{
1020-
if (MobileBreakpoint.HasValue && breakpoint <= MobileBreakpoint )
1021+
if (MobileBreakpoint.HasValue && breakpoint <= MobileBreakpoint)
10211022
{
10221023
MobileView = true;
10231024
}
@@ -1028,5 +1029,18 @@ protected void OnBreakpointChanged(Breakpoint breakpoint)
10281029
StateHasChanged();
10291030
}
10301031

1032+
/// <summary>
1033+
///
1034+
/// </summary>
1035+
/// <param name="args"></param>
1036+
/// <param name="step"></param>
1037+
protected async Task HandleHeaderKeyDown(KeyboardEventArgs args, MudStepExtended step)
1038+
{
1039+
if (args.Key == "Enter" || args.Key == "NumpadEnter")
1040+
{
1041+
await GoToStepByReferenceAsync(step);
1042+
}
1043+
}
1044+
10311045
}
10321046
}

0 commit comments

Comments
 (0)