PR U-1: AccountSelector reacts to Accounts arriving late

Move the SelectedAccount = Accounts.FirstOrDefault(...) lookup from
OnInitialized to OnParametersSet so the preselection tracks the
Accounts list arriving asynchronously (every caller now passes []
first and hydrates after an await). Idempotent — the OnSelectedChanged
callback path returns the same AccountId back and the parent re-render
lookup finds the same account.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Claudio Schaad 2026-07-03 19:17:41 +02:00
parent e6efdb5f3a
commit 60f01d437c

View file

@ -14,7 +14,11 @@ public partial class AccountSelector : ComponentBase
private Account? SelectedAccount { get; set; } 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); SelectedAccount = Accounts.FirstOrDefault(account => account.Id == AccountId);
} }