From d20414188b36ec7b19305cefa7bc860db9f91f62 Mon Sep 17 00:00:00 2001 From: Robert Dyer Date: Wed, 3 Jul 2024 09:47:50 -0500 Subject: [PATCH 1/6] Automatically focus inputs, or the primary button, in modals. --- .../src/components/accounts/Account.jsx | 2 +- .../components/accounts/AccountSyncCheck.jsx | 2 +- .../src/components/accounts/Reconcile.jsx | 2 +- .../src/components/manager/ImportActual.tsx | 1 + .../src/components/manager/ImportYNAB4.tsx | 1 + .../src/components/manager/ImportYNAB5.tsx | 1 + .../src/components/manager/WelcomeScreen.tsx | 2 +- .../components/modals/CloseAccountModal.tsx | 1 + .../modals/ConfirmTransactionDelete.tsx | 23 +++++++++-------- .../modals/ConfirmTransactionEdit.tsx | 21 +++++++++------- .../modals/ConfirmUnlinkAccount.tsx | 21 +++++++++------- .../components/modals/CreateAccountModal.tsx | 25 +++++++++++-------- .../modals/GoCardlessInitialise.tsx | 21 +++++++++------- .../components/modals/ImportTransactions.jsx | 1 + .../components/modals/MergeUnusedPayees.jsx | 1 + .../components/modals/SimpleFinInitialise.tsx | 1 + .../components/reports/SaveReportDelete.tsx | 6 ++--- .../schedules/PostsOfflineNotification.jsx | 2 +- .../components/schedules/ScheduleDetails.jsx | 21 +++++++++------- .../src/components/schedules/ScheduleLink.tsx | 19 ++++++++------ .../select/RecurringSchedulePicker.jsx | 19 ++++++++------ 21 files changed, 112 insertions(+), 81 deletions(-) diff --git a/packages/desktop-client/src/components/accounts/Account.jsx b/packages/desktop-client/src/components/accounts/Account.jsx index 5ae43fe427..d66496c375 100644 --- a/packages/desktop-client/src/components/accounts/Account.jsx +++ b/packages/desktop-client/src/components/accounts/Account.jsx @@ -73,7 +73,7 @@ function EmptyMessage({ onAdd }) { manage it locally yourself. - diff --git a/packages/desktop-client/src/components/accounts/AccountSyncCheck.jsx b/packages/desktop-client/src/components/accounts/AccountSyncCheck.jsx index 989e585c76..587618bb6b 100644 --- a/packages/desktop-client/src/components/accounts/AccountSyncCheck.jsx +++ b/packages/desktop-client/src/components/accounts/AccountSyncCheck.jsx @@ -130,7 +130,7 @@ export function AccountSyncCheck() { {showAuth ? ( <> - diff --git a/packages/desktop-client/src/components/accounts/Reconcile.jsx b/packages/desktop-client/src/components/accounts/Reconcile.jsx index d80668b8e1..b1d721e769 100644 --- a/packages/desktop-client/src/components/accounts/Reconcile.jsx +++ b/packages/desktop-client/src/components/accounts/Reconcile.jsx @@ -78,7 +78,7 @@ export function ReconcilingMessage({ )} - diff --git a/packages/desktop-client/src/components/manager/ImportActual.tsx b/packages/desktop-client/src/components/manager/ImportActual.tsx index a6863deb53..a7433092c1 100644 --- a/packages/desktop-client/src/components/manager/ImportActual.tsx +++ b/packages/desktop-client/src/components/manager/ImportActual.tsx @@ -84,6 +84,7 @@ export function ImportActual({ modalProps }: ImportProps) { diff --git a/packages/desktop-client/src/components/manager/ImportYNAB4.tsx b/packages/desktop-client/src/components/manager/ImportYNAB4.tsx index 338a5dd5e2..d215c2e77c 100644 --- a/packages/desktop-client/src/components/manager/ImportYNAB4.tsx +++ b/packages/desktop-client/src/components/manager/ImportYNAB4.tsx @@ -73,6 +73,7 @@ export function ImportYNAB4({ modalProps }: ImportProps) { diff --git a/packages/desktop-client/src/components/manager/ImportYNAB5.tsx b/packages/desktop-client/src/components/manager/ImportYNAB5.tsx index da108febd9..2606cd819d 100644 --- a/packages/desktop-client/src/components/manager/ImportYNAB5.tsx +++ b/packages/desktop-client/src/components/manager/ImportYNAB5.tsx @@ -83,6 +83,7 @@ export function ImportYNAB5({ modalProps }: ImportProps) { diff --git a/packages/desktop-client/src/components/manager/WelcomeScreen.tsx b/packages/desktop-client/src/components/manager/WelcomeScreen.tsx index ce72529ec5..912ddfe702 100644 --- a/packages/desktop-client/src/components/manager/WelcomeScreen.tsx +++ b/packages/desktop-client/src/components/manager/WelcomeScreen.tsx @@ -75,7 +75,7 @@ export function WelcomeScreen() { - diff --git a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx index fb9d8411f4..c608b90f14 100644 --- a/packages/desktop-client/src/components/modals/CloseAccountModal.tsx +++ b/packages/desktop-client/src/components/modals/CloseAccountModal.tsx @@ -149,6 +149,7 @@ export function CloseAccountModal({ value={transferAccountId} inputProps={{ placeholder: 'Select account...', + autoFocus: true, ...(isNarrowWidth && { value: transferAccount?.name || '', style: { diff --git a/packages/desktop-client/src/components/modals/ConfirmTransactionDelete.tsx b/packages/desktop-client/src/components/modals/ConfirmTransactionDelete.tsx index 6d465b8e0e..c125df9b2b 100644 --- a/packages/desktop-client/src/components/modals/ConfirmTransactionDelete.tsx +++ b/packages/desktop-client/src/components/modals/ConfirmTransactionDelete.tsx @@ -7,6 +7,7 @@ import { Modal } from '../common/Modal'; import { Paragraph } from '../common/Paragraph'; import { View } from '../common/View'; import { type CommonModalProps } from '../Modals'; +import { InitialFocus } from '../common/InitialFocus'; type ConfirmTransactionDeleteProps = { modalProps: CommonModalProps; @@ -43,16 +44,18 @@ export function ConfirmTransactionDelete({ > Cancel - + + + diff --git a/packages/desktop-client/src/components/modals/ConfirmTransactionEdit.tsx b/packages/desktop-client/src/components/modals/ConfirmTransactionEdit.tsx index 6fb4c80077..eb0ca6abc6 100644 --- a/packages/desktop-client/src/components/modals/ConfirmTransactionEdit.tsx +++ b/packages/desktop-client/src/components/modals/ConfirmTransactionEdit.tsx @@ -6,6 +6,7 @@ import { Button } from '../common/Button'; import { Modal } from '../common/Modal'; import { View } from '../common/View'; import { type CommonModalProps } from '../Modals'; +import { InitialFocus } from '../common/InitialFocus'; type ConfirmTransactionEditProps = { modalProps: Partial; @@ -74,15 +75,17 @@ export function ConfirmTransactionEdit({ - + + + diff --git a/packages/desktop-client/src/components/modals/ConfirmUnlinkAccount.tsx b/packages/desktop-client/src/components/modals/ConfirmUnlinkAccount.tsx index 68174829a6..b496de1de6 100644 --- a/packages/desktop-client/src/components/modals/ConfirmUnlinkAccount.tsx +++ b/packages/desktop-client/src/components/modals/ConfirmUnlinkAccount.tsx @@ -5,6 +5,7 @@ import { Modal } from '../common/Modal'; import { Paragraph } from '../common/Paragraph'; import { View } from '../common/View'; import { type CommonModalProps } from '../Modals'; +import { InitialFocus } from '../common/InitialFocus'; type ConfirmUnlinkAccountProps = { modalProps: CommonModalProps; @@ -39,15 +40,17 @@ export function ConfirmUnlinkAccount({ - + + + )} diff --git a/packages/desktop-client/src/components/modals/CreateAccountModal.tsx b/packages/desktop-client/src/components/modals/CreateAccountModal.tsx index 4f042cd1d5..ddc40a50cc 100644 --- a/packages/desktop-client/src/components/modals/CreateAccountModal.tsx +++ b/packages/desktop-client/src/components/modals/CreateAccountModal.tsx @@ -20,6 +20,7 @@ import { Text } from '../common/Text'; import { View } from '../common/View'; import { type CommonModalProps } from '../Modals'; import { Tooltip } from '../tooltips'; +import { InitialFocus } from '../common/InitialFocus'; type CreateAccountProps = { modalProps: CommonModalProps; @@ -183,17 +184,19 @@ export function CreateAccountModal({ {upgradingAccountId == null && ( - + + + Create a local account if you want to add diff --git a/packages/desktop-client/src/components/modals/GoCardlessInitialise.tsx b/packages/desktop-client/src/components/modals/GoCardlessInitialise.tsx index 8857962e0e..0c5ce8e121 100644 --- a/packages/desktop-client/src/components/modals/GoCardlessInitialise.tsx +++ b/packages/desktop-client/src/components/modals/GoCardlessInitialise.tsx @@ -12,6 +12,7 @@ import type { ModalProps } from '../common/Modal'; import { Text } from '../common/Text'; import { View } from '../common/View'; import { FormField, FormLabel } from '../forms'; +import { InitialFocus } from '../common/InitialFocus'; type GoCardlessInitialiseProps = { modalProps?: Partial; @@ -70,15 +71,17 @@ export const GoCardlessInitialise = ({ - { - setSecretId(value); - setIsValid(true); - }} - /> + + { + setSecretId(value); + setIsValid(true); + }} + /> + diff --git a/packages/desktop-client/src/components/modals/ImportTransactions.jsx b/packages/desktop-client/src/components/modals/ImportTransactions.jsx index 26abe34e46..5d0eb440bd 100644 --- a/packages/desktop-client/src/components/modals/ImportTransactions.jsx +++ b/packages/desktop-client/src/components/modals/ImportTransactions.jsx @@ -1285,6 +1285,7 @@ export function ImportTransactions({ modalProps, options }) { > - diff --git a/packages/desktop-client/src/components/schedules/PostsOfflineNotification.jsx b/packages/desktop-client/src/components/schedules/PostsOfflineNotification.jsx index 6073a87bab..dcfc71cabe 100644 --- a/packages/desktop-client/src/components/schedules/PostsOfflineNotification.jsx +++ b/packages/desktop-client/src/components/schedules/PostsOfflineNotification.jsx @@ -69,7 +69,7 @@ export function PostsOfflineNotification({ modalProps, actions }) { spacing={2} > - diff --git a/packages/desktop-client/src/components/schedules/ScheduleDetails.jsx b/packages/desktop-client/src/components/schedules/ScheduleDetails.jsx index 442676cb3a..292672233d 100644 --- a/packages/desktop-client/src/components/schedules/ScheduleDetails.jsx +++ b/packages/desktop-client/src/components/schedules/ScheduleDetails.jsx @@ -16,6 +16,7 @@ import { theme } from '../../style'; import { AccountAutocomplete } from '../autocomplete/AccountAutocomplete'; import { PayeeAutocomplete } from '../autocomplete/PayeeAutocomplete'; import { Button } from '../common/Button'; +import { InitialFocus } from '../common/InitialFocus'; import { Modal } from '../common/Modal'; import { Stack } from '../common/Stack'; import { Text } from '../common/Text'; @@ -456,15 +457,17 @@ export function ScheduleDetails({ modalProps, actions, id, transaction }) { - { - dispatch({ type: 'set-field', field: 'name', value: e }); - }} - /> + + { + dispatch({ type: 'set-field', field: 'name', value: e }); + }} + /> + diff --git a/packages/desktop-client/src/components/schedules/ScheduleLink.tsx b/packages/desktop-client/src/components/schedules/ScheduleLink.tsx index 5743087d3f..ea6de5bdfe 100644 --- a/packages/desktop-client/src/components/schedules/ScheduleLink.tsx +++ b/packages/desktop-client/src/components/schedules/ScheduleLink.tsx @@ -18,6 +18,7 @@ import { View } from '../common/View'; import { type CommonModalProps } from '../Modals'; import { ROW_HEIGHT, SchedulesTable } from './SchedulesTable'; +import { InitialFocus } from '../common/InitialFocus'; export function ScheduleLink({ modalProps, @@ -80,14 +81,16 @@ export function ScheduleLink({ : `this transaction belongs`}{' '} to: - + + + {ids.length === 1 && (