Set inital focus on category when covering overspending (#7012)

* Set inital focus on category when covering overspending

* Fixup: Make sure that the amount is set

* Unused import

* Fix bug where typing an amount and pressing enter uses previous value

---------

Co-authored-by: Dagur Ammendrup <dagurp@vivaldi.com>
This commit is contained in:
Dagur Páll Ammendrup
2026-02-19 18:51:07 +00:00
committed by GitHub
parent ce890faeeb
commit 6460af3de4
2 changed files with 14 additions and 9 deletions

View File

@@ -3,7 +3,6 @@ import { Form } from 'react-aria-components';
import { Trans, useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
import { InitialFocus } from '@actual-app/components/initial-focus';
import { Input } from '@actual-app/components/input';
import { styles } from '@actual-app/components/styles';
import { View } from '@actual-app/components/view';
@@ -53,7 +52,7 @@ export function CoverMenu({
}, [categoryId, showToBeBudgeted, originalCategoryGroups]);
const _initialAmount = integerToCurrency(Math.abs(initialAmount ?? 0));
const [amount, setAmount] = useState<string | null>(null);
const [amount, setAmount] = useState<string>(_initialAmount);
function _onSubmit() {
const parsedAmount = evalArithmetic(amount || '');
@@ -75,13 +74,12 @@ export function CoverMenu({
<Trans>Cover this amount:</Trans>
</View>
<View>
<InitialFocus>
<Input
defaultValue={_initialAmount}
onUpdate={setAmount}
style={styles.tnum}
/>
</InitialFocus>
<Input
defaultValue={_initialAmount}
onUpdate={setAmount}
onChangeValue={setAmount}
style={styles.tnum}
/>
</View>
<View style={{ margin: '10px 0 5px 0' }}>
<Trans>From:</Trans>
@@ -90,6 +88,7 @@ export function CoverMenu({
<CategoryAutocomplete
categoryGroups={filteredCategoryGroups}
value={null}
focused
openOnFocus
onSelect={(id: string | undefined) => setFromCategoryId(id || null)}
inputProps={{

View File

@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [Dagur]
---
When covering overspending the initial focus should be on the category, not the amount.