diff --git a/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor.cs b/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor.cs index 8fac290..643bf2c 100644 --- a/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor.cs +++ b/Schaad.Accounting.UI/Components/Pages/Controls/AccountSelector.razor.cs @@ -14,7 +14,11 @@ public partial class AccountSelector : ComponentBase private Account? SelectedAccount { get; set; } - protected override void OnInitialized() + // OnParametersSet, not OnInitialized: OnInitialized fires once, but callers now + // pass an empty Accounts list on first render and hydrate it after an await. + // OnParametersSet re-runs the lookup whenever Accounts or AccountId change, so the + // preselection tracks late-arriving data. + protected override void OnParametersSet() { SelectedAccount = Accounts.FirstOrDefault(account => account.Id == AccountId); }