Skip to content

Commit 09ab2ab

Browse files
committed
Improved checkbox aria-label identification
1 parent 473864d commit 09ab2ab

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

src/CodeBeam.MudBlazor.Extensions/Components/ListExtended/MudListItemExtended.razor

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,18 @@
8282
<div class="@MultiSelectClassName">
8383
@if (OverrideMultiSelectionComponent == null ? MudListExtended?.MultiSelectionComponent == MultiSelectionComponent.CheckBox : OverrideMultiSelectionComponent.Value == MultiSelectionComponent.CheckBox)
8484
{
85-
<MudCheckBox Color="@(MudListExtended?.Color ?? Color.Default)" Disabled="@GetDisabledStatus()" @bind-Value="_selected" @onclick="OnClickHandler" Dense="true" />
85+
<MudCheckBox Color="@(MudListExtended?.Color ?? Color.Default)" Disabled="@GetDisabledStatus()" @bind-Value="_selected" @onclick="OnClickHandler" Dense="true"
86+
aria-label="@($"Select {AccessibleName}")" />
8687
}
8788
else if (OverrideMultiSelectionComponent == null ? MudListExtended?.MultiSelectionComponent == MultiSelectionComponent.Switch : OverrideMultiSelectionComponent.Value == MultiSelectionComponent.Switch)
8889
{
89-
<MudSwitch Color="@(MudListExtended?.Color ?? Color.Default)" Disabled="@GetDisabledStatus()" @bind-Value="_selected" @onclick="OnClickHandler" StopClickPropagation="true" />
90+
<MudSwitch Color="@(MudListExtended?.Color ?? Color.Default)" Disabled="@GetDisabledStatus()" @bind-Value="_selected" @onclick="OnClickHandler" StopClickPropagation="true"
91+
aria-label="@($"Select {AccessibleName}")" />
9092
}
9193
else if (OverrideMultiSelectionComponent == null ? MudListExtended?.MultiSelectionComponent == MultiSelectionComponent.SwitchM3 : OverrideMultiSelectionComponent.Value == MultiSelectionComponent.SwitchM3)
9294
{
93-
<MudSwitchM3 Color="@(MudListExtended?.Color ?? Color.Default)" Disabled="@GetDisabledStatus()" @bind-Value="_selected" @onclick="OnClickHandler" StopClickPropagation="true" />
95+
<MudSwitchM3 Color="@(MudListExtended?.Color ?? Color.Default)" Disabled="@GetDisabledStatus()" @bind-Value="_selected" @onclick="OnClickHandler" StopClickPropagation="true"
96+
aria-label="@($"Select {AccessibleName}")" />
9497
}
9598
</div>
9699
}

tests/CodeBeam.MudBlazor.Extensions.UnitTests/Components/SelectExtendedTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ public void MultiSelect_Items_Should_Expose_Checkbox_AriaLabel_And_TestId()
5757
item.GetAttribute("role").Should().Be("option");
5858
var checkbox = item.QuerySelector("input[type=checkbox]");
5959
checkbox.Should().NotBeNull();
60-
var ariaLabel = checkbox.GetAttribute("aria-label");
61-
ariaLabel.Should().NotBeNullOrEmpty();
6260
var optionAria = item.GetAttribute("aria-label");
6361
optionAria.Should().NotBeNullOrEmpty();
64-
optionAria.Trim().Should().Be(ariaLabel.Trim());
62+
var checkboxAria = checkbox.GetAttribute("aria-label");
63+
checkboxAria.Should().NotBeNullOrEmpty();
64+
checkboxAria.Trim().Should().Be($"Select {optionAria.Trim()}");
6565
}
6666

6767
// Note: MudSelect doesn't guaranteed the consequences of changing Value if MultiSelection is true for now.

0 commit comments

Comments
 (0)