Skip to content

A local-first personal finance app

Improve monte carlo contributions tab on mobile (#8709)

Michael Clark13db5123ee1b
diff --git a/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloConfiguration.tsx b/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloConfiguration.tsx
index 427f6e6e62..9ee8082f40 100644
--- a/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloConfiguration.tsx
+++ b/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloConfiguration.tsx
@@ -123,8 +123,8 @@ export function MonteCarloConfiguration({
gap: 15,
}}
>
- {/* Tab bar */}
- <View style={{ flexDirection: 'row', gap: 5 }}>
+ {/* Tab bar; wraps onto extra lines on narrow screens */}
+ <View style={{ flexDirection: 'row', flexWrap: 'wrap', gap: 5 }}>
<ModeButton
selected={activeTab === 'plan'}
onSelect={() => setActiveTab('plan')}
diff --git a/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloContributions.tsx b/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloContributions.tsx
index df623dec0b..a82966dc79 100644
--- a/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloContributions.tsx
+++ b/packages/desktop-client/src/components/reports/reports/monte-carlo/MonteCarloContributions.tsx
@@ -94,135 +94,150 @@ export function MonteCarloContributions({
return (
<View style={{ gap: 10 }}>
- <View style={{ ...styles.tableContainer, flex: 'unset' }}>
- <TableHeader>
- <Field width="flex" style={{ minWidth: 150 }}>
- <Trans>Contribution name</Trans>
- </Field>
- <Field width="flex" style={{ minWidth: 160 }}>
- <Trans>Into pot</Trans>
- </Field>
- <Field width="flex" style={{ minWidth: 100 }}>
- <Trans>From age</Trans>
- </Field>
- <Field width="flex" style={{ minWidth: 100 }}>
- <Trans>To age</Trans>
- </Field>
- <Field width="flex" style={{ minWidth: 140 }}>
- <Trans>Amount (per year)</Trans>
- </Field>
- <Field width="flex" style={{ minWidth: 170 }} />
- <Field width={36} />
- </TableHeader>
-
- {contributions.map((contribution, index) => (
- <Row
- key={contribution.id}
- collapsed
- height={CONTRIBUTION_ROW_HEIGHT}
- style={{
- backgroundColor: theme.tableBackground,
- ':hover': { backgroundColor: theme.tableRowBackgroundHover },
- }}
- >
- <Field width="flex" style={{ minWidth: 150 }} truncate={false}>
- <Input
- defaultValue={contribution.name}
- placeholder={t('Contribution {{number}}', {
- number: index + 1,
- })}
- aria-label={t('Contribution name')}
- onUpdate={newName => {
- if (newName !== contribution.name) {
- updateContribution(contribution.id, { name: newName });
- }
- }}
- />
+ <View
+ style={{
+ ...styles.tableContainer,
+ ...styles.horizontalScrollbar,
+ flex: 'unset',
+ // Scroll sideways when the columns' minimum widths don't fit,
+ // instead of clipping the end of the rows
+ overflowX: 'auto',
+ }}
+ >
+ <View style={{ minWidth: 'fit-content' }}>
+ <TableHeader>
+ <Field width="flex" style={{ minWidth: 150 }}>
+ <Trans>Contribution name</Trans>
</Field>
-
- <Field width="flex" style={{ minWidth: 160 }} truncate={false}>
- <Select
- value={contribution.potId}
- onChange={value =>
- updateContribution(contribution.id, { potId: value })
- }
- options={potOptions}
- />
+ <Field width="flex" style={{ minWidth: 160 }}>
+ <Trans>Into pot</Trans>
</Field>
-
- <Field width="flex" style={{ minWidth: 100 }} truncate={false}>
- <MonteCarloNumberInput
- value={contribution.fromAge}
- aria-label={t('From age')}
- allowEmpty
- roundToInteger
- min={currentAge}
- max={contribution.toAge ?? targetAge}
- step={1}
- placeholder={t('Now')}
- onCommit={newValue =>
- updateContribution(contribution.id, { fromAge: newValue })
- }
- />
+ <Field width="flex" style={{ minWidth: 100 }}>
+ <Trans>From age</Trans>
</Field>
-
- <Field width="flex" style={{ minWidth: 100 }} truncate={false}>
- <MonteCarloNumberInput
- value={contribution.toAge}
- aria-label={t('To age')}
- allowEmpty
- roundToInteger
- min={contribution.fromAge ?? currentAge}
- max={targetAge}
- step={1}
- placeholder={t('End of plan')}
- onCommit={newValue =>
- updateContribution(contribution.id, { toAge: newValue })
- }
- />
+ <Field width="flex" style={{ minWidth: 100 }}>
+ <Trans>To age</Trans>
</Field>
-
- <Field width="flex" style={{ minWidth: 140 }} truncate={false}>
- <FinancialInput
- value={contribution.annualAmount}
- aria-label={t('Amount (per year)')}
- onUpdate={value => {
- const newAmount = Math.min(MAX_AMOUNT, Math.max(0, value));
- if (newAmount !== contribution.annualAmount) {
+ <Field width="flex" style={{ minWidth: 140 }}>
+ <Trans>Amount (per year)</Trans>
+ </Field>
+ <Field width="flex" style={{ minWidth: 170 }} />
+ <Field width={36} />
+ </TableHeader>
+
+ {contributions.map((contribution, index) => (
+ <Row
+ key={contribution.id}
+ collapsed
+ height={CONTRIBUTION_ROW_HEIGHT}
+ style={{
+ backgroundColor: theme.tableBackground,
+ ':hover': { backgroundColor: theme.tableRowBackgroundHover },
+ }}
+ >
+ <Field width="flex" style={{ minWidth: 150 }} truncate={false}>
+ <Input
+ defaultValue={contribution.name}
+ placeholder={t('Contribution {{number}}', {
+ number: index + 1,
+ })}
+ aria-label={t('Contribution name')}
+ onUpdate={newName => {
+ if (newName !== contribution.name) {
+ updateContribution(contribution.id, { name: newName });
+ }
+ }}
+ />
+ </Field>
+
+ <Field width="flex" style={{ minWidth: 160 }} truncate={false}>
+ <Select
+ value={contribution.potId}
+ onChange={value =>
+ updateContribution(contribution.id, { potId: value })
+ }
+ options={potOptions}
+ />
+ </Field>
+
+ <Field width="flex" style={{ minWidth: 100 }} truncate={false}>
+ <MonteCarloNumberInput
+ value={contribution.fromAge}
+ aria-label={t('From age')}
+ allowEmpty
+ roundToInteger
+ min={currentAge}
+ max={contribution.toAge ?? targetAge}
+ step={1}
+ placeholder={t('Now')}
+ onCommit={newValue =>
+ updateContribution(contribution.id, { fromAge: newValue })
+ }
+ />
+ </Field>
+
+ <Field width="flex" style={{ minWidth: 100 }} truncate={false}>
+ <MonteCarloNumberInput
+ value={contribution.toAge}
+ aria-label={t('To age')}
+ allowEmpty
+ roundToInteger
+ min={contribution.fromAge ?? currentAge}
+ max={targetAge}
+ step={1}
+ placeholder={t('End of plan')}
+ onCommit={newValue =>
+ updateContribution(contribution.id, { toAge: newValue })
+ }
+ />
+ </Field>
+
+ <Field width="flex" style={{ minWidth: 140 }} truncate={false}>
+ <FinancialInput
+ value={contribution.annualAmount}
+ aria-label={t('Amount (per year)')}
+ onUpdate={value => {
+ const newAmount = Math.min(MAX_AMOUNT, Math.max(0, value));
+ if (newAmount !== contribution.annualAmount) {
+ updateContribution(contribution.id, {
+ annualAmount: newAmount,
+ });
+ }
+ }}
+ />
+ </Field>
+
+ <Field width="flex" style={{ minWidth: 170 }} truncate={false}>
+ <LabeledCheckbox
+ id={`contribution-inflation-${contribution.id}`}
+ checked={contribution.adjustsWithInflation}
+ onChange={event =>
updateContribution(contribution.id, {
- annualAmount: newAmount,
- });
+ adjustsWithInflation: event.target.checked,
+ })
}
- }}
- />
- </Field>
-
- <Field width="flex" style={{ minWidth: 170 }} truncate={false}>
- <LabeledCheckbox
- id={`contribution-inflation-${contribution.id}`}
- checked={contribution.adjustsWithInflation}
- onChange={event =>
- updateContribution(contribution.id, {
- adjustsWithInflation: event.target.checked,
- })
- }
+ >
+ <Trans>Adjust by inflation</Trans>
+ </LabeledCheckbox>
+ </Field>
+
+ <Field
+ width={36}
+ truncate={false}
+ style={{ alignItems: 'center' }}
>
- <Trans>Adjust by inflation</Trans>
- </LabeledCheckbox>
- </Field>
-
- <Field width={36} truncate={false} style={{ alignItems: 'center' }}>
- <Button
- variant="bare"
- aria-label={t('Remove contribution')}
- onPress={() => removeContribution(contribution.id)}
- style={{ padding: 6 }}
- >
- <SvgDelete width={12} height={12} />
- </Button>
- </Field>
- </Row>
- ))}
+ <Button
+ variant="bare"
+ aria-label={t('Remove contribution')}
+ onPress={() => removeContribution(contribution.id)}
+ style={{ padding: 6 }}
+ >
+ <SvgDelete width={12} height={12} />
+ </Button>
+ </Field>
+ </Row>
+ ))}
+ </View>
</View>
<View style={{ flexDirection: 'row' }}>
diff --git a/upcoming-release-notes/monte-carlo-mobile-responsiveness.md b/upcoming-release-notes/monte-carlo-mobile-responsiveness.md
new file mode 100644
index 0000000000..63b0ce13ab
--- /dev/null
+++ b/upcoming-release-notes/monte-carlo-mobile-responsiveness.md
@@ -0,0 +1,6 @@
+---
+category: Bugfix
+authors: [MikesGlitch]
+---
+
+Fix the Monte Carlo analysis configuration tabs and contributions table overflowing on small screens