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:
parent
e6efdb5f3a
commit
60f01d437c
1 changed files with 5 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue