mirror of
https://github.com/radzenhq/radzen-blazor.git
synced 2026-07-08 18:16:08 +00:00
FormField: fix invalid/empty label for association
RadzenFormField rendered for="@Component" on the wrapping <div> (invalid - <div> does not take for) and on the label even when Component was unset, producing for="" which accessibility checkers flag as a label with no association. Removed the div for and only emit the label for when Component is set. Updated the FormFieldTextBox demo to give each input an id matching the FormField Component so the label resolves.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
|
||||
@if (Visible)
|
||||
{
|
||||
<div @ref="@Element" for="@Component" style="@Style" @attributes="Attributes" class="@GetCssClass()" id="@GetId()">
|
||||
<div @ref="@Element" style="@Style" @attributes="Attributes" class="@GetCssClass()" id="@GetId()">
|
||||
<div class="rz-form-field-content">
|
||||
<CascadingValue Value=@context>
|
||||
@if (Start != null)
|
||||
@@ -13,7 +13,7 @@
|
||||
</div>
|
||||
}
|
||||
@ChildContent
|
||||
<label class="rz-form-field-label rz-text-truncate" for=@Component> @if (TextTemplate is null) {@Text} else {@TextTemplate} </label>
|
||||
<label class="rz-form-field-label rz-text-truncate" for="@(string.IsNullOrEmpty(Component) ? null : Component)"> @if (TextTemplate is null) {@Text} else {@TextTemplate} </label>
|
||||
@if (End != null)
|
||||
{
|
||||
<div class="rz-form-field-end">
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
<RadzenRow AlignItems="AlignItems.End" Wrap="FlexWrap.Wrap" Gap="1rem" class="rz-p-sm-12">
|
||||
<RadzenColumn Size="12" SizeMD="6" SizeLG="3">
|
||||
<RadzenFormField Text="Outlined/Default" Style="width: 100%;">
|
||||
<RadzenTextBox @bind-Value="@value" />
|
||||
<RadzenFormField Text="Outlined/Default" Component="FormFieldTextBoxOutlined" Style="width: 100%;">
|
||||
<RadzenTextBox id="FormFieldTextBoxOutlined" @bind-Value="@value" />
|
||||
</RadzenFormField>
|
||||
</RadzenColumn>
|
||||
<RadzenColumn Size="12" SizeMD="6" SizeLG="3">
|
||||
<RadzenFormField Text="Text" Variant="Variant.Text" Style="width: 100%;">
|
||||
<RadzenTextBox @bind-Value="@value" />
|
||||
<RadzenFormField Text="Text" Variant="Variant.Text" Component="FormFieldTextBoxText" Style="width: 100%;">
|
||||
<RadzenTextBox id="FormFieldTextBoxText" @bind-Value="@value" />
|
||||
</RadzenFormField>
|
||||
</RadzenColumn>
|
||||
<RadzenColumn Size="12" SizeMD="6" SizeLG="3">
|
||||
<RadzenFormField Text="Flat" Variant="Variant.Flat" Style="width: 100%;">
|
||||
<RadzenTextBox @bind-Value="@value" />
|
||||
<RadzenFormField Text="Flat" Variant="Variant.Flat" Component="FormFieldTextBoxFlat" Style="width: 100%;">
|
||||
<RadzenTextBox id="FormFieldTextBoxFlat" @bind-Value="@value" />
|
||||
</RadzenFormField>
|
||||
</RadzenColumn>
|
||||
<RadzenColumn Size="12" SizeMD="6" SizeLG="3">
|
||||
<RadzenFormField Text="Filled" Variant="Variant.Filled" Style="width: 100%;">
|
||||
<RadzenTextBox @bind-Value="@value" />
|
||||
<RadzenFormField Text="Filled" Variant="Variant.Filled" Component="FormFieldTextBoxFilled" Style="width: 100%;">
|
||||
<RadzenTextBox id="FormFieldTextBoxFilled" @bind-Value="@value" />
|
||||
</RadzenFormField>
|
||||
</RadzenColumn>
|
||||
</RadzenRow>
|
||||
|
||||
Reference in New Issue
Block a user