A local-first personal finance app
monte carlo linked account feedback (#8847)
Michael Clarkca50d46d827c
diff --git a/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloPotConfiguration.tsx b/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloPotConfiguration.tsxindex 00cc70fc45..3c445f738f 100644--- a/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloPotConfiguration.tsx+++ b/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloPotConfiguration.tsx@@ -76,7 +76,12 @@ export function MonteCarloPotConfiguration({// A linked account that has since been closed or deleted isn't in the// open-accounts list; keep it represented so the stored link doesn't// display as a blank selection- const openAccounts = accounts.filter(account => account.closed === 0);+ const openAccounts = accounts+ .filter(account => account.closed === 0)+ // Budgeted accounts first, then off-budget, each keeping the user's+ // sidebar drag order (the query already sorts by sort_order) - the+ // same order the sidebar shows+ .sort((accountA, accountB) => accountA.offbudget - accountB.offbudget);const linkedAccount = accounts.find(account => account.id === pot.accountId);const missingLinkedOptions: Array<[string, string]> =pot.accountId != null &&@@ -137,7 +142,10 @@ export function MonteCarloPotConfiguration({><Input// Uncontrolled on purpose: committing on blur keeps typing- // snappy since every config change re-runs the simulation+ // snappy since every config change re-runs the simulation.+ // The key remounts it when the linked account changes, so an+ // auto-filled name actually shows up+ key={pot.accountId ?? 'manual'}defaultValue={pot.name}placeholder={t('Pot {{number}}', { number: potNumber })}onUpdate={newName => {@@ -177,9 +185,25 @@ export function MonteCarloPotConfiguration({><Selectvalue={pot.accountId ?? ''}- onChange={value =>- onPotChange({ accountId: value === '' ? null : value })- }+ onChange={value => {+ const newAccountId = value === '' ? null : value;+ const newAccount = accounts.find(+ account => account.id === newAccountId,+ );+ const previousAccount = accounts.find(+ account => account.id === pot.accountId,+ );+ // Default the pot's name to the account's, but only when+ // the current name isn't the user's own: empty, or still+ // the auto-filled name of the previously linked account+ const shouldFillName =+ newAccount != null &&+ (pot.name === '' || pot.name === previousAccount?.name);+ onPotChange({+ accountId: newAccountId,+ ...(shouldFillName && { name: newAccount.name }),+ });+ }}options={[['', t('None')],...missingLinkedOptions,diff --git a/upcoming-release-notes/monte-carlo-linked-account-polish.md b/upcoming-release-notes/monte-carlo-linked-account-polish.mdnew file mode 100644index 0000000000..11bcaee856--- /dev/null+++ b/upcoming-release-notes/monte-carlo-linked-account-polish.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [MikesGlitch]+---++Name Monte Carlo pots after their linked account automatically, and list accounts in the same order as the sidebar