Skip to content
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
2 changes: 1 addition & 1 deletion src/Core/Components/List/FluentSelect.razor
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@typeparam TOption
<CascadingValue Value="_internalListContext" Name="ListContext" TValue="InternalListContext<TOption>" IsFixed="true">
@InlineStyleValue
<FluentInputLabel ForId="@Id" Label="@Label" AriaLabel="@AriaLabel" Required="@Required" ChildContent="@LabelTemplate" />
<FluentInputLabel ForId="@Id" Label="@Label" AriaLabel="@GetAriaLabelWithRequired()" Required="@Required" ChildContent="@LabelTemplate" />
<fluent-select @ref=Element
id=@Id
class="@ClassValue"
Expand Down
12 changes: 12 additions & 0 deletions src/Core/Components/List/FluentSelect.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace Microsoft.FluentUI.AspNetCore.Components;
[CascadingTypeParameter(nameof(TOption))]
public partial class FluentSelect<TOption> : ListComponentBase<TOption> where TOption : notnull
{
/// <summary>
/// Gets the `Required` aria label.
/// </summary>
public static string RequiredAriaLabel = "Required";

/// <summary />
protected virtual MarkupString InlineStyleValue => new InlineStyleBuilder()
.AddStyle($"#{Id}::part(listbox)", "max-height", Height, !string.IsNullOrWhiteSpace(Height))
Expand Down Expand Up @@ -39,4 +44,11 @@ public partial class FluentSelect<TOption> : ListComponentBase<TOption> where TO
/// </summary>
[Parameter]
public Appearance? Appearance { get; set; }

private string? GetAriaLabelWithRequired()
{
var label = AriaLabel ?? Label ?? Title ?? string.Empty;

return label + (Required ? $", {RequiredAriaLabel}" : string.Empty);
}
}