Skip to content

Fix Blazor activation render ordering and update dependencies#4318

Merged
glennawatson merged 1 commit intomainfrom
fix/blazor-activation-render-ordering
Apr 2, 2026
Merged

Fix Blazor activation render ordering and update dependencies#4318
glennawatson merged 1 commit intomainfrom
fix/blazor-activation-render-ordering

Conversation

@glennawatson
Copy link
Copy Markdown
Contributor

What changed for end users

Blazor components (ReactiveComponentBase, ReactiveInjectableComponentBase, ReactiveLayoutComponentBase, ReactiveOwningComponentBase) had a lifecycle ordering bug where property changes made during WhenActivated were not reflected in the UI. This happened because:

  1. WhenActivated fires during OnInitialized -- your Rx chains execute and set reactive properties
  2. Blazor renders the component
  3. ViewModel change subscriptions are wired in OnAfterRender -- too late to catch changes from step 1

The fix adds a StateHasChanged() call after wiring subscriptions in OnAfterRender so the component re-renders with the latest state from activation. This results in one additional render cycle on first load but ensures the UI is always consistent.

Fixes #4317

Dependency updates

Package From To
TUnit 1.17.54 1.24.18
bunit 2.6.2 2.7.2
Microsoft.SourceLink.GitHub 10.0.103 10.0.201
Microsoft.AspNetCore.Components (net8) 8.0.24 8.0.25
Microsoft.AspNetCore.Components (net9) 9.0.13 9.0.14
Microsoft.AspNetCore.Components (net10) 10.0.3 10.0.5
Microsoft.Testing.Extensions.CodeCoverage 18.4.1 18.5.2
Verify.TUnit 31.13.2 31.14.0
Microsoft.Xaml.Behaviors.Wpf 1.1.135/1.1.141 1.1.142
Microsoft.Maui.Controls (net10 only) 10.0.41 10.0.51
Xamarin.AndroidX.Preference 1.2.1.16 1.2.1.17
Xamarin.AndroidX.Lifecycle.LiveData 2.10.0.1 2.10.0.2
Xamarin.AndroidX.Fragment 1.8.9.1 1.8.9.2
Xamarin.AndroidX.Collection.Jvm 1.5.0.4 1.5.0.5
Xamarin.AndroidX.SavedState 1.4.0.1 1.4.0.2

TUnit implicit usings were enabled to match TUnit 1.24 requirements. One test assertion was updated for TUnit 1.24 compatibility (nullable Func evaluation change).

Test plan

  • All 12,514 tests pass across net8.0, net9.0, net10.0
  • Full solution build succeeds with 0 warnings, 0 errors
  • Blazor test render counts updated to reflect the additional activation render

- Fix Blazor OnActivate notification ordering: property changes during
  WhenActivated (OnInitialized) were missed because change subscriptions
  were not wired until OnAfterRender. Added a re-render after wiring
  subscriptions to pick up activation-phase changes. Applied to all four
  Blazor component base classes.
- Update TUnit 1.17.54 to 1.24.18, enable implicit usings
- Update bunit 2.6.2 to 2.7.2
- Update Microsoft.SourceLink.GitHub 10.0.103 to 10.0.201
- Update Microsoft.AspNetCore.Components 8.0.24/9.0.13/10.0.3 to 8.0.25/9.0.14/10.0.5
- Update Microsoft.Testing.Extensions.CodeCoverage 18.4.1 to 18.5.2
- Update Verify.TUnit 31.13.2 to 31.14.0
- Update Microsoft.Xaml.Behaviors.Wpf to 1.1.142 (all TFMs)
- Update Microsoft.Maui.Controls 10.0.41 to 10.0.51 (net10 only)
- Update Xamarin.AndroidX.Preference 1.2.1.16 to 1.2.1.17
- Update Xamarin.AndroidX.Lifecycle.LiveData 2.10.0.1 to 2.10.0.2
- Update Xamarin.AndroidX.Fragment 1.8.9.1 to 1.8.9.2
- Update Xamarin.AndroidX.Collection.Jvm 1.5.0.4 to 1.5.0.5
- Update Xamarin.AndroidX.SavedState 1.4.0.1 to 1.4.0.2
- Fix TUnit 1.24 test compatibility for nullable Func assertion
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.68%. Comparing base (1645c9a) to head (6616a46).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4318   +/-   ##
=======================================
  Coverage   89.68%   89.68%           
=======================================
  Files         251      251           
  Lines        9618     9571   -47     
  Branches     1460     1460           
=======================================
- Hits         8626     8584   -42     
+ Misses        753      747    -6     
- Partials      239      240    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@glennawatson glennawatson merged commit 223b928 into main Apr 2, 2026
6 checks passed
@glennawatson glennawatson deleted the fix/blazor-activation-render-ordering branch April 2, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ReactiveUI Blazor OnActivate notification issue

2 participants