File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed
bunit.testassets/SampleComponents Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -447,15 +447,23 @@ protected override void ProcessPendingRender()
447
447
/// <inheritdoc/>
448
448
protected override Task UpdateDisplayAsync ( in RenderBatch renderBatch )
449
449
{
450
+ var disposedComponentIds = new HashSet < int > ( ) ;
450
451
for ( var i = 0 ; i < renderBatch . DisposedComponentIDs . Count ; i ++ )
451
452
{
452
453
var id = renderBatch . DisposedComponentIDs . Array [ i ] ;
454
+ disposedComponentIds . Add ( id ) ;
453
455
returnedRenderedComponentIds . Remove ( id ) ;
454
456
}
455
457
456
458
for ( var i = 0 ; i < renderBatch . UpdatedComponents . Count ; i ++ )
457
459
{
458
460
var diff = renderBatch . UpdatedComponents . Array [ i ] ;
461
+
462
+ if ( disposedComponentIds . Contains ( diff . ComponentId ) )
463
+ {
464
+ continue ;
465
+ }
466
+
459
467
var componentState = GetComponentState ( diff . ComponentId ) ;
460
468
var renderedComponent = ( IRenderedComponent ) componentState ;
461
469
Original file line number Diff line number Diff line change
1
+ <EditForm Model =" model" OnValidSubmit =" SetInvoked" >
2
+ <DataAnnotationsValidator />
3
+
4
+ <InputText id =" title" @bind-Value =" model.Title" />
5
+ <button >Submit</button >
6
+ </EditForm >
7
+
8
+ @code {
9
+
10
+ [Parameter ]
11
+ public bool Invoked { get ; set ; }
12
+
13
+ private Model model = new ();
14
+
15
+ private void SetInvoked ()
16
+ {
17
+ Invoked = true ;
18
+ model = new Model ();
19
+ }
20
+
21
+ public sealed class Model
22
+ {
23
+ public string ? Title { get ; set ; }
24
+ }
25
+
26
+ }
Original file line number Diff line number Diff line change @@ -244,6 +244,17 @@ public void Test024()
244
244
245
245
text . ShouldNotBeNull ( ) ;
246
246
}
247
+
248
+ [ Fact ( DisplayName = "Form submission with DataAnnotationsValidator and model recreation works correctly" ) ]
249
+ public void Test025 ( )
250
+ {
251
+ var cut = Render < FormWithValidation > ( ) ;
252
+ cut . Find ( "#title" ) . Change ( "title" ) ;
253
+
254
+ cut . Find ( "form" ) . Submit ( ) ;
255
+
256
+ cut . Instance . Invoked . ShouldBeTrue ( ) ;
257
+ }
247
258
248
259
private class BaseComponent : ComponentBase
249
260
{
You can’t perform that action at this time.
0 commit comments