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()
447447 /// <inheritdoc/>
448448 protected override Task UpdateDisplayAsync ( in RenderBatch renderBatch )
449449 {
450+ var disposedComponentIds = new HashSet < int > ( ) ;
450451 for ( var i = 0 ; i < renderBatch . DisposedComponentIDs . Count ; i ++ )
451452 {
452453 var id = renderBatch . DisposedComponentIDs . Array [ i ] ;
454+ disposedComponentIds . Add ( id ) ;
453455 returnedRenderedComponentIds . Remove ( id ) ;
454456 }
455457
456458 for ( var i = 0 ; i < renderBatch . UpdatedComponents . Count ; i ++ )
457459 {
458460 var diff = renderBatch . UpdatedComponents . Array [ i ] ;
461+
462+ if ( disposedComponentIds . Contains ( diff . ComponentId ) )
463+ {
464+ continue ;
465+ }
466+
459467 var componentState = GetComponentState ( diff . ComponentId ) ;
460468 var renderedComponent = ( IRenderedComponent ) componentState ;
461469
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()
244244
245245 text . ShouldNotBeNull ( ) ;
246246 }
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+ }
247258
248259 private class BaseComponent : ComponentBase
249260 {
You can’t perform that action at this time.
0 commit comments