Skip to content

A local-first personal finance app

Extract mobile rules form to a new page (#5516)

Matiss Janis Aboltins692ade7254e9
diff --git a/.prettierignore b/.prettierignore
index 7d569880c6..e900c652d1 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -7,6 +7,8 @@ packages/api/migrations
packages/crdt/dist
packages/component-library/src/icons/**/*
packages/desktop-client/bundle.browser.js
+packages/desktop-client/stats.json
+packages/desktop-client/.swc/
packages/desktop-client/build/
packages/desktop-client/locale/
packages/desktop-client/build-electron/
@@ -23,5 +25,6 @@ packages/desktop-electron/dist/
packages/loot-core/**/node_modules/*
packages/loot-core/**/lib-dist/*
packages/loot-core/**/proto/*
+packages/sync-server/coverage/
.yarn/*
upcoming-release-notes/*
diff --git a/package.json b/package.json
index 08950719da..3995067608 100644
--- a/package.json
+++ b/package.json
@@ -41,6 +41,7 @@
"test:debug": "yarn workspaces foreach --all --verbose run test",
"e2e": "yarn workspaces foreach --all --exclude desktop-electron --parallel --verbose run e2e",
"e2e:desktop": "yarn build:desktop --skip-exe-build && yarn workspace desktop-electron e2e",
+ "playwright": "yarn workspace @actual-app/web run playwright",
"vrt": "yarn workspaces foreach --all --parallel --verbose run vrt",
"vrt:docker": "./bin/run-vrt",
"rebuild-electron": "./node_modules/.bin/electron-rebuild -f -m ./packages/loot-core",
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts b/packages/desktop-client/e2e/rules.mobile.test.ts
index a143b5f521..42fbad3348 100644
--- a/packages/desktop-client/e2e/rules.mobile.test.ts
+++ b/packages/desktop-client/e2e/rules.mobile.test.ts
@@ -52,24 +52,22 @@ test.describe('Mobile Rules', () => {
await expect(page).toMatchThemeScreenshots();
});
- test('clicking add button opens rule creation modal', async () => {
+ test('clicking add button opens rule creation form', async () => {
await rulesPage.clickAddRule();
- // Check that edit rule modal is opened
- const modal = page.getByRole('dialog');
- await expect(modal).toBeVisible();
await expect(page).toMatchThemeScreenshots();
});
- test('clicking on a rule opens edit modal', async () => {
+ test('clicking on a rule opens edit form', async () => {
const ruleCount = await rulesPage.getRuleCount();
expect(ruleCount).toBeGreaterThan(0);
await rulesPage.clickRule(0);
- // Check that edit rule modal is opened
- const modal = page.getByRole('dialog');
- await expect(modal).toBeVisible();
+ // Click on the header to have consistent focused element
+ // (otherwise sometimes the condition field is "hovered" and thus has a different background color)
+ await page.getByRole('heading', { name: 'Edit Rule' }).click();
+
await expect(page).toMatchThemeScreenshots();
});
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-form-1-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-form-1-chromium-linux.png
new file mode 100644
index 0000000000..be6f383a33
Binary files /dev/null and b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-form-1-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-form-2-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-form-2-chromium-linux.png
new file mode 100644
index 0000000000..9d79884150
Binary files /dev/null and b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-form-2-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-form-3-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-form-3-chromium-linux.png
new file mode 100644
index 0000000000..2ba9393f11
Binary files /dev/null and b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-form-3-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-modal-1-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-modal-1-chromium-linux.png
deleted file mode 100644
index ef83abe282..0000000000
Binary files a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-modal-1-chromium-linux.png and /dev/null differ
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-modal-2-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-modal-2-chromium-linux.png
deleted file mode 100644
index b94658273b..0000000000
Binary files a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-modal-2-chromium-linux.png and /dev/null differ
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-modal-3-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-modal-3-chromium-linux.png
deleted file mode 100644
index a98d8fe681..0000000000
Binary files a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-add-button-opens-rule-creation-modal-3-chromium-linux.png and /dev/null differ
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-form-1-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-form-1-chromium-linux.png
new file mode 100644
index 0000000000..753c00aec2
Binary files /dev/null and b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-form-1-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-form-2-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-form-2-chromium-linux.png
new file mode 100644
index 0000000000..469c970717
Binary files /dev/null and b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-form-2-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-form-3-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-form-3-chromium-linux.png
new file mode 100644
index 0000000000..edde75b8fd
Binary files /dev/null and b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-form-3-chromium-linux.png differ
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-modal-1-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-modal-1-chromium-linux.png
deleted file mode 100644
index 9539c7484e..0000000000
Binary files a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-modal-1-chromium-linux.png and /dev/null differ
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-modal-2-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-modal-2-chromium-linux.png
deleted file mode 100644
index 4523e7f0e1..0000000000
Binary files a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-modal-2-chromium-linux.png and /dev/null differ
diff --git a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-modal-3-chromium-linux.png b/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-modal-3-chromium-linux.png
deleted file mode 100644
index ca7cbf073d..0000000000
Binary files a/packages/desktop-client/e2e/rules.mobile.test.ts-snapshots/Mobile-Rules-clicking-on-a-rule-opens-edit-modal-3-chromium-linux.png and /dev/null differ
diff --git a/packages/desktop-client/src/components/FinancesApp.tsx b/packages/desktop-client/src/components/FinancesApp.tsx
index 2d47a5c4cf..91ddabd9d7 100644
--- a/packages/desktop-client/src/components/FinancesApp.tsx
+++ b/packages/desktop-client/src/components/FinancesApp.tsx
@@ -259,6 +259,10 @@ export function FinancesApp() {
path="/rules"
element={<NarrowAlternate name="Rules" />}
/>
+ <Route
+ path="/rules/:id"
+ element={<NarrowAlternate name="RuleEdit" />}
+ />
<Route path="/bank-sync" element={<BankSync />} />
<Route path="/tags" element={<ManageTagsPage />} />
<Route path="/settings" element={<Settings />} />
diff --git a/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx b/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx
index c9991d9d79..5f544b2590 100644
--- a/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx
+++ b/packages/desktop-client/src/components/autocomplete/Autocomplete.tsx
@@ -51,6 +51,7 @@ type CommonAutocompleteProps<T extends AutocompleteItem> = {
clearOnSelect?: boolean;
closeOnBlur?: boolean;
closeOnSelect?: boolean;
+ updateOnValueChange?: boolean;
onClose?: () => void;
};
@@ -234,6 +235,7 @@ function SingleAutocomplete<T extends AutocompleteItem>({
clearOnSelect = false,
closeOnBlur = true,
closeOnSelect = !clearOnSelect,
+ updateOnValueChange = false,
onClose,
value: initialValue,
}: SingleAutocompleteProps<T>) {
@@ -261,11 +263,12 @@ function SingleAutocomplete<T extends AutocompleteItem>({
const itemsViewRef = useRef(null);
const { isNarrowWidth } = useResponsive();
- const narrowInputStyle = isNarrowWidth
- ? {
- ...styles.mobileMenuItem,
- }
- : {};
+ const narrowInputStyle =
+ embedded && isNarrowWidth
+ ? {
+ ...styles.mobileMenuItem,
+ }
+ : {};
inputProps = {
...inputProps,
@@ -281,6 +284,16 @@ function SingleAutocomplete<T extends AutocompleteItem>({
setSelectedItem(findItem(strict, suggestions, initialValue));
}, [initialValue, suggestions, strict]);
+ // Sometimes (khem, khem.. on mobile) we want to force update
+ // the "value" field (which is also used as a search term) if
+ // the initial value changes.
+ useEffect(() => {
+ if (updateOnValueChange) {
+ const item = findItem(strict, suggestions, initialValue);
+ setValue(item ? getItemName(item) : '');
+ }
+ }, [strict, suggestions, initialValue, updateOnValueChange]);
+
function resetState(newValue?: string) {
const val = newValue === undefined ? initialValue : newValue;
const selectedItem = findItem<T>(strict, suggestions, val);
diff --git a/packages/desktop-client/src/components/mobile/rules/AddRuleButton.tsx b/packages/desktop-client/src/components/mobile/rules/AddRuleButton.tsx
index 969f641053..6be024a607 100644
--- a/packages/desktop-client/src/components/mobile/rules/AddRuleButton.tsx
+++ b/packages/desktop-client/src/components/mobile/rules/AddRuleButton.tsx
@@ -1,59 +1,23 @@
-import React from 'react';
+import React, { useCallback } from 'react';
+import { useTranslation } from 'react-i18next';
import { Button } from '@actual-app/components/button';
import { SvgAdd } from '@actual-app/components/icons/v1';
-import { type NewRuleEntity } from 'loot-core/types/models';
+import { useNavigate } from '@desktop-client/hooks/useNavigate';
-import { pushModal } from '@desktop-client/modals/modalsSlice';
-import { useDispatch } from '@desktop-client/redux';
+export function AddRuleButton() {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
-type AddRuleButtonProps = {
- onRuleAdded: () => void;
-};
-
-export function AddRuleButton({ onRuleAdded }: AddRuleButtonProps) {
- const dispatch = useDispatch();
-
- const handleAddRule = () => {
- const newRule: NewRuleEntity = {
- stage: 'pre',
- conditionsOp: 'and',
- conditions: [
- {
- field: 'payee',
- op: 'is',
- value: '',
- type: 'id',
- },
- ],
- actions: [
- {
- field: 'category',
- op: 'set',
- value: '',
- type: 'id',
- },
- ],
- };
-
- dispatch(
- pushModal({
- modal: {
- name: 'edit-rule',
- options: {
- rule: newRule,
- onSave: onRuleAdded,
- },
- },
- }),
- );
- };
+ const handleAddRule = useCallback(() => {
+ navigate('/rules/new');
+ }, [navigate]);
return (
<Button
variant="bare"
- aria-label="Add new rule"
+ aria-label={t('Add new rule')}
style={{ margin: 10 }}
onPress={handleAddRule}
>
diff --git a/packages/desktop-client/src/components/mobile/rules/MobileRuleEditPage.tsx b/packages/desktop-client/src/components/mobile/rules/MobileRuleEditPage.tsx
new file mode 100644
index 0000000000..f7d48919cd
--- /dev/null
+++ b/packages/desktop-client/src/components/mobile/rules/MobileRuleEditPage.tsx
@@ -0,0 +1,133 @@
+import React, { useEffect, useState } from 'react';
+import { useTranslation, Trans } from 'react-i18next';
+import { useParams } from 'react-router';
+
+import { Text } from '@actual-app/components/text';
+import { theme } from '@actual-app/components/theme';
+import { View } from '@actual-app/components/view';
+
+import { send } from 'loot-core/platform/client/fetch';
+import { type RuleEntity, type NewRuleEntity } from 'loot-core/types/models';
+
+import { MobileBackButton } from '@desktop-client/components/mobile/MobileBackButton';
+import { MobilePageHeader, Page } from '@desktop-client/components/Page';
+import { RuleEditor } from '@desktop-client/components/rules/RuleEditor';
+import { useNavigate } from '@desktop-client/hooks/useNavigate';
+
+export function MobileRuleEditPage() {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
+ const { id } = useParams<{ id?: string }>();
+
+ const [rule, setRule] = useState<RuleEntity | null>(null);
+ const [isLoading, setIsLoading] = useState(false);
+
+ // Load rule by ID if we're in edit mode
+ useEffect(() => {
+ if (id && id !== 'new') {
+ setIsLoading(true);
+ send('rule-get', { id })
+ .then(loadedRule => {
+ if (loadedRule) {
+ setRule(loadedRule);
+ } else {
+ // Rule not found, navigate back to rules list
+ navigate('/rules');
+ }
+ })
+ .catch(error => {
+ console.error('Failed to load rule:', error);
+ // Navigate back to rules list if rule not found
+ navigate('/rules');
+ })
+ .finally(() => {
+ setIsLoading(false);
+ });
+ }
+ }, [id, navigate]);
+
+ // If no rule is provided, create a new one
+ const defaultRule: NewRuleEntity = rule || {
+ stage: 'pre',
+ conditionsOp: 'and',
+ conditions: [
+ {
+ field: 'payee',
+ op: 'is',
+ value: '',
+ type: 'id',
+ },
+ ],
+ actions: [
+ {
+ field: 'category',
+ op: 'set',
+ value: '',
+ type: 'id',
+ },
+ ],
+ };
+
+ const handleSave = () => {
+ // Navigate back to rules list
+ navigate('/rules');
+ };
+
+ const handleCancel = () => {
+ navigate('/rules');
+ };
+
+ const isEditing = Boolean(id && id !== 'new' && rule);
+ const pageTitle = isEditing ? t('Edit Rule') : t('Create Rule');
+
+ // Show loading state while fetching rule
+ if (isLoading) {
+ return (
+ <Page
+ header={
+ <MobilePageHeader
+ title={t('Loading...')}
+ leftContent={<MobileBackButton onPress={handleCancel} />}
+ />
+ }
+ padding={0}
+ >
+ <View
+ style={{
+ flex: 1,
+ backgroundColor: theme.mobilePageBackground,
+ justifyContent: 'center',
+ alignItems: 'center',
+ }}
+ >
+ <Text>
+ <Trans>Loading rule...</Trans>
+ </Text>
+ </View>
+ </Page>
+ );
+ }
+
+ return (
+ <Page
+ header={
+ <MobilePageHeader
+ title={pageTitle}
+ leftContent={<MobileBackButton onPress={handleCancel} />}
+ />
+ }
+ padding={0}
+ >
+ <RuleEditor
+ rule={defaultRule}
+ onSave={handleSave}
+ onCancel={handleCancel}
+ style={{
+ paddingTop: 10,
+ flex: 1,
+ backgroundColor: theme.mobilePageBackground,
+ }}
+ />
+ </Page>
+ );
+}
diff --git a/packages/desktop-client/src/components/mobile/rules/MobileRulesPage.tsx b/packages/desktop-client/src/components/mobile/rules/MobileRulesPage.tsx
index 2350b14546..df43e711f5 100644
--- a/packages/desktop-client/src/components/mobile/rules/MobileRulesPage.tsx
+++ b/packages/desktop-client/src/components/mobile/rules/MobileRulesPage.tsx
@@ -18,16 +18,15 @@ import { ruleToString } from '@desktop-client/components/ManageRules';
import { MobilePageHeader, Page } from '@desktop-client/components/Page';
import { useAccounts } from '@desktop-client/hooks/useAccounts';
import { useCategories } from '@desktop-client/hooks/useCategories';
+import { useNavigate } from '@desktop-client/hooks/useNavigate';
import { usePayees } from '@desktop-client/hooks/usePayees';
import { useSchedules } from '@desktop-client/hooks/useSchedules';
-import { pushModal } from '@desktop-client/modals/modalsSlice';
-import { useDispatch } from '@desktop-client/redux';
const PAGE_SIZE = 50;
export function MobileRulesPage() {
const { t } = useTranslation();
- const dispatch = useDispatch();
+ const navigate = useNavigate();
const [allRules, setAllRules] = useState<RuleEntity[]>([]);
const [isLoading, setIsLoading] = useState(true);
const [hasMoreRules, setHasMoreRules] = useState(true);
@@ -86,19 +85,12 @@ export function MobileRulesPage() {
loadRules();
}, [loadRules]);
- const handleRulePress = (rule: RuleEntity) => {
- dispatch(
- pushModal({
- modal: {
- name: 'edit-rule',
- options: {
- rule,
- onSave: () => loadRules(),
- },
- },
- }),
- );
- };
+ const handleRulePress = useCallback(
+ (rule: RuleEntity) => {
+ navigate(`/rules/${rule.id}`);
+ },
+ [navigate],
+ );
const handleLoadMore = useCallback(() => {
if (!isLoading && hasMoreRules && !filter) {
@@ -106,10 +98,6 @@ export function MobileRulesPage() {
}
}, [isLoading, hasMoreRules, filter, loadRules]);
- const handleRuleAdded = () => {
- loadRules();
- };
-
const onSearchChange = useCallback(
(value: string) => {
setFilter(value);
@@ -120,10 +108,7 @@ export function MobileRulesPage() {
return (
<Page
header={
- <MobilePageHeader
- title={t('Rules')}
- rightContent={<AddRuleButton onRuleAdded={handleRuleAdded} />}
- />
+ <MobilePageHeader title={t('Rules')} rightContent={<AddRuleButton />} />
}
padding={0}
>
diff --git a/packages/desktop-client/src/components/responsive/narrow.ts b/packages/desktop-client/src/components/responsive/narrow.ts
index 2f63ad277d..45c82ae19b 100644
--- a/packages/desktop-client/src/components/responsive/narrow.ts
+++ b/packages/desktop-client/src/components/responsive/narrow.ts
@@ -4,5 +4,6 @@ export { AccountsPage as Accounts } from '../mobile/accounts/AccountsPage';
export { AccountPage as Account } from '../mobile/accounts/AccountPage';
export { MobileRulesPage as Rules } from '../mobile/rules/MobileRulesPage';
+export { MobileRuleEditPage as RuleEdit } from '../mobile/rules/MobileRuleEditPage';
export { CategoryPage as Category } from '../mobile/budget/CategoryPage';
diff --git a/packages/desktop-client/src/components/responsive/wide.ts b/packages/desktop-client/src/components/responsive/wide.ts
index e0869334f5..b95d1f5260 100644
--- a/packages/desktop-client/src/components/responsive/wide.ts
+++ b/packages/desktop-client/src/components/responsive/wide.ts
@@ -8,6 +8,7 @@ export { Account as Accounts } from '../accounts/Account';
export { Account } from '../accounts/Account';
export { ManageRulesPage as Rules } from '../ManageRulesPage';
+export { ManageRulesPage as RuleEdit } from '../ManageRulesPage';
export { UserDirectoryPage } from '../admin/UserDirectory/UserDirectoryPage';
diff --git a/packages/desktop-client/src/components/rules/RuleEditor.tsx b/packages/desktop-client/src/components/rules/RuleEditor.tsx
index 7275bc1534..3e869e2b03 100644
--- a/packages/desktop-client/src/components/rules/RuleEditor.tsx
+++ b/packages/desktop-client/src/components/rules/RuleEditor.tsx
@@ -10,6 +10,7 @@ import {
import { useTranslation, Trans } from 'react-i18next';
import { Button } from '@actual-app/components/button';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import {
SvgDelete,
SvgAdd,
@@ -65,7 +66,10 @@ import { DisplayId } from '@desktop-client/components/util/DisplayId';
import { GenericInput } from '@desktop-client/components/util/GenericInput';
import { useDateFormat } from '@desktop-client/hooks/useDateFormat';
import { useFeatureFlag } from '@desktop-client/hooks/useFeatureFlag';
-import { useSchedules } from '@desktop-client/hooks/useSchedules';
+import {
+ useSchedules,
+ type ScheduleStatusType,
+} from '@desktop-client/hooks/useSchedules';
import {
useSelected,
SelectedProvider,
@@ -369,6 +373,7 @@ function formatAmount(amount) {
}
function ScheduleDescription({ id }) {
+ const { isNarrowWidth } = useResponsive();
const dateFormat = useDateFormat() || 'MM/dd/yyyy';
const scheduleQuery = useMemo(
() => q('schedules').filter({ id }).select('*'),
@@ -384,12 +389,13 @@ function ScheduleDescription({ id }) {
return null;
}
- if (schedules.length === 0) {
+ const [schedule] = schedules;
+
+ if (schedule && schedules.length === 0) {
return <View style={{ flex: 1 }}>{id}</View>;
}
- const [schedule] = schedules;
- const status = schedule && statusLabels.get(schedule.id);
+ const status = statusLabels.get(schedule.id) as ScheduleStatusType;
return (
<View
@@ -427,8 +433,7 @@ function ScheduleDescription({ id }) {
</Trans>
</Text>
</SpaceBetween>
- {/* @ts-expect-error fix this */}
- <StatusBadge status={status} />
+ {!isNarrowWidth && <StatusBadge status={status} />}
</View>
);
}
@@ -1206,9 +1211,10 @@ export function RuleEditor({
innerRef={scrollableEl}
style={{
borderBottom: '1px solid ' + theme.tableBorder,
- padding: 20,
+ padding: '0 20px 20px 20px',
overflow: 'auto',
maxHeight: 'calc(100% - 300px)',
+ minHeight: 100,
}}
>
<View style={{ flexShrink: 0 }}>
@@ -1347,10 +1353,13 @@ export function RuleEditor({
<SelectedProvider instance={selectedInst}>
<View style={{ padding: '20px', flex: 1 }}>
- <View
+ <SpaceBetween
+ direction="horizontal"
+ gap={5}
style={{
flexDirection: 'row',
- alignItems: 'center',
+ flexWrap: 'nowrap',
+ justifyContent: 'space-between',
marginBottom: 12,
}}
>
@@ -1358,14 +1367,13 @@ export function RuleEditor({
<Trans>This rule applies to these transactions:</Trans>
</Text>
- <View style={{ flex: 1 }} />
<Button
isDisabled={selectedInst.items.size === 0}
onPress={onApply}
>
<Trans>Apply actions</Trans> ({selectedInst.items.size})
</Button>
- </View>
+ </SpaceBetween>
{/* @ts-expect-error fix this */}
<SimpleTransactionsTable
diff --git a/packages/desktop-client/src/components/util/GenericInput.jsx b/packages/desktop-client/src/components/util/GenericInput.jsx
index 4f906155df..fb7120cca0 100644
--- a/packages/desktop-client/src/components/util/GenericInput.jsx
+++ b/packages/desktop-client/src/components/util/GenericInput.jsx
@@ -1,6 +1,7 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
+import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { Input } from '@actual-app/components/input';
import { View } from '@actual-app/components/view';
@@ -22,7 +23,8 @@ import { RecurringSchedulePicker } from '@desktop-client/components/select/Recur
import { useCategories } from '@desktop-client/hooks/useCategories';
import { useDateFormat } from '@desktop-client/hooks/useDateFormat';
import { useReports } from '@desktop-client/hooks/useReports';
-import { useSelector } from '@desktop-client/redux';
+import { pushModal } from '@desktop-client/modals/modalsSlice';
+import { useSelector, useDispatch } from '@desktop-client/redux';
export function GenericInput({
field,
@@ -36,12 +38,30 @@ export function GenericInput({
onChange,
op = undefined,
}) {
+ const dispatch = useDispatch();
+ const { isNarrowWidth } = useResponsive();
const { t } = useTranslation();
const { grouped: categoryGroups } = useCategories();
const { data: savedReports } = useReports();
const saved = useSelector(state => state.queries.saved);
const dateFormat = useDateFormat() || 'MM/dd/yyyy';
+ // Helper function to open autocomplete modal with safe event handling
+ const openAutocompleteModal = modalName => {
+ dispatch(
+ pushModal({
+ modal: {
+ name: modalName,
+ options: {
+ onSelect: newValue => {
+ onChange(multi ? [...value, newValue] : newValue);
+ },
+ },
+ },
+ }),
+ );
+ };
+
const getNumberInputByFormatType = numberFormatType => {
switch (numberFormatType) {
case 'currency':
@@ -91,12 +111,20 @@ export function GenericInput({
<PayeeAutocomplete
type={autocompleteType}
showMakeTransfer={false}
- openOnFocus={true}
+ openOnFocus={!isNarrowWidth}
+ updateOnValueChange={isNarrowWidth}
value={value}
onSelect={onChange}
inputProps={{
ref,
...(showPlaceholder ? { placeholder: t('nothing') } : null),
+ onClick: () => {
+ if (!isNarrowWidth) {
+ return;
+ }
+
+ openAutocompleteModal('payee-autocomplete');
+ },
}}
/>
);
@@ -113,11 +141,19 @@ export function GenericInput({
<AccountAutocomplete
type={autocompleteType}
value={value}
- openOnFocus={true}
+ openOnFocus={!isNarrowWidth}
+ updateOnValueChange={isNarrowWidth}
onSelect={onChange}
inputProps={{
ref,
...(showPlaceholder ? { placeholder: t('nothing') } : null),
+ onClick: () => {
+ if (!isNarrowWidth) {
+ return;
+ }
+
+ openAutocompleteModal('account-autocomplete');
+ },
}}
/>
);
@@ -131,12 +167,20 @@ export function GenericInput({
type={autocompleteType}
categoryGroups={categoryGroups}
value={value}
- openOnFocus={true}
+ openOnFocus={!isNarrowWidth}
+ updateOnValueChange={isNarrowWidth}
onSelect={onChange}
showHiddenCategories={true}
inputProps={{
ref,
...(showPlaceholder ? { placeholder: t('nothing') } : null),
+ onClick: () => {
+ if (!isNarrowWidth) {
+ return;
+ }
+
+ openAutocompleteModal('category-autocomplete');
+ },
}}
/>
);
diff --git a/upcoming-release-notes/5516.md b/upcoming-release-notes/5516.md
new file mode 100644
index 0000000000..498a39fe68
--- /dev/null
+++ b/upcoming-release-notes/5516.md
@@ -0,0 +1,7 @@
+---
+category: Enhancements
+authors: [MatissJanis]
+---
+
+Extract mobile rules editing to a dedicated page, enhancing user navigation and experience.
+