File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed
src/Components/Web/src/Forms Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -8,21 +8,19 @@ namespace Microsoft.AspNetCore.Components.Forms;
8
8
/// </summary>
9
9
internal sealed class InputRadioContext
10
10
{
11
+ private readonly Func < object ? > _valueGetter ;
12
+
11
13
public InputRadioContext ? ParentContext { get ; }
12
14
public EventCallback < ChangeEventArgs > ChangeEventCallback { get ; }
15
+ public object ? CurrentValue => _valueGetter ( ) ;
13
16
14
17
// Mutable properties that may change any time an InputRadioGroup is rendered
15
18
public string ? GroupName { get ; set ; }
16
- public object ? CurrentValue { get ; set ; }
17
19
public string ? FieldClass { get ; set ; }
18
20
19
- /// <summary>
20
- /// Instantiates a new <see cref="InputRadioContext" />.
21
- /// </summary>
22
- /// <param name="parentContext">The parent context, if any.</param>
23
- /// <param name="changeEventCallback">The event callback to be invoked when the selected value is changed.</param>
24
- public InputRadioContext ( InputRadioContext ? parentContext , EventCallback < ChangeEventArgs > changeEventCallback )
21
+ public InputRadioContext ( Func < object ? > valueGetter , InputRadioContext ? parentContext , EventCallback < ChangeEventArgs > changeEventCallback )
25
22
{
23
+ _valueGetter = valueGetter ;
26
24
ParentContext = parentContext ;
27
25
ChangeEventCallback = changeEventCallback ;
28
26
}
Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ protected override void OnParametersSet()
34
34
if ( _context is null )
35
35
{
36
36
var changeEventCallback = EventCallback . Factory . CreateBinder < string ? > ( this , __value => CurrentValueAsString = __value , CurrentValueAsString ) ;
37
- _context = new InputRadioContext ( CascadedContext , changeEventCallback ) ;
37
+ _context = new InputRadioContext ( ( ) => CurrentValue , CascadedContext , changeEventCallback ) ;
38
38
}
39
39
else if ( _context . ParentContext != CascadedContext )
40
40
{
@@ -59,7 +59,7 @@ protected override void OnParametersSet()
59
59
// Otherwise, just use a GUID to disambiguate this group's radio inputs from any others on the page.
60
60
_context . GroupName = _defaultGroupName ;
61
61
}
62
- _context . CurrentValue = CurrentValue ;
62
+
63
63
_context . FieldClass = EditContext ? . FieldCssClass ( FieldIdentifier ) ;
64
64
}
65
65
You can’t perform that action at this time.
0 commit comments