Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FluentRadioGroup] Fix binding error #2742

Merged
merged 3 commits into from
Oct 1, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -8084,7 +8084,7 @@
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentRadio`1.Context">
<summary>
Gets context for this <see cref="T:Microsoft.FluentUI.AspNetCore.Components.FluentRadio`1"/>.
Gets context for this <see cref="T:Microsoft.FluentUI.AspNetCore.Components.FluentRadio`1"/>.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentRadio`1.ReadOnly">
Expand Down Expand Up @@ -8137,7 +8137,7 @@
Gets or sets the content to be rendered inside the component.
</summary>
</member>
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentRadio`1.OnInitialized">
<member name="M:Microsoft.FluentUI.AspNetCore.Components.FluentRadio`1.OnParametersSet">
<inheritdoc />
</member>
<member name="T:Microsoft.FluentUI.AspNetCore.Components.FluentRadioContext">
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Components/List/FluentSelect.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public partial class FluentSelect<TOption> : ListComponentBase<TOption> where TO

private string? GetAriaLabelWithRequired()
{
#pragma warning disable CS0618 // Type or member is obsolete
var label = AriaLabel ?? Label ?? Title ?? string.Empty;
#pragma warning restore CS0618 // Type or member is obsolete

return label + (Required ? $", {RequiredAriaLabel}" : string.Empty);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Components/Radio/FluentRadio.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Microsoft.FluentUI.AspNetCore.Components;
public partial class FluentRadio<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] TValue> : FluentComponentBase
{
/// <summary>
/// Gets context for this <see cref="FluentRadio{TValue}"/>.
/// Gets context for this <see cref="FluentRadio{TValue}"/>.
/// </summary>
internal FluentRadioContext? Context { get; private set; }

Expand Down Expand Up @@ -78,7 +78,7 @@ public FluentRadio()
}

/// <inheritdoc />
protected override void OnInitialized()
protected override void OnParametersSet()
{
Context = string.IsNullOrEmpty(Name) ? CascadedContext : CascadedContext?.FindContextInAncestors(Name);

Expand Down
1 change: 1 addition & 0 deletions src/Core/Components/Radio/FluentRadioGroup.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
name="@_context!.GroupName"
orientation="@Orientation.ToAttributeValue()"
required="@Required"
value="@CurrentValueAsString"
@onradiogroupchange="HandleChange"
@attributes="AdditionalAttributes">
@ChildContent
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Components/Radio/FluentRadioGroup.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected override void OnParametersSet()
else if (_context.ParentContext != CascadedContext)
{
// This should never be possible in any known usage pattern, but if it happens, we want to know
throw new InvalidOperationException("An FluentRadioGroup cannot change context after creation");
throw new InvalidOperationException("A FluentRadioGroup cannot change context after creation");
}

// Mutate the FluentRadioContext instance in place. Since this is a non-fixed cascading parameter, the descendant
Expand All @@ -65,7 +65,7 @@ protected override bool TryParseValueFromString(string? value, [MaybeNullWhen(fa

private void HandleChange(ChangeEventArgs e)
{
if (CurrentValueAsString != e?.Value?.ToString())
if (CurrentValueAsString != e?.Value?.ToString() && e?.Value is not null)
{
CurrentValueAsString = e?.Value?.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

<fluent-radio-group id="xxx" name="xxx" blazor:onradiogroupclick="1" blazor:elementreference="xxx">
<fluent-radio-group id="xxx" name="xxx" value="False" blazor:onradiogroupclick="1" blazor:elementreference="xxx">
<b>render me</b>
</fluent-radio-group>
Loading