Skip to content

Commit c2e2ade

Browse files
committed
♻️ removing 'focused' prop from generic Input component
1 parent 60a864a commit c2e2ade

File tree

9 files changed

+17
-34
lines changed

9 files changed

+17
-34
lines changed

packages/desktop-client/src/components/accounts/Reconcile.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import React, { useState } from 'react';
22
import { Trans } from 'react-i18next';
33

44
import { Button } from '@actual-app/components/button';
5+
import { SvgCheckCircle1 } from '@actual-app/components/icons/v2';
56
import { InitialFocus } from '@actual-app/components/initial-focus';
67
import { styles } from '@actual-app/components/styles';
78
import { Text } from '@actual-app/components/text';
9+
import { theme } from '@actual-app/components/theme';
810
import { View } from '@actual-app/components/view';
911

1012
import * as queries from 'loot-core/client/queries';
@@ -13,8 +15,6 @@ import { currencyToInteger } from 'loot-core/shared/util';
1315
import { type AccountEntity } from 'loot-core/types/models';
1416
import { type TransObjectLiteral } from 'loot-core/types/util';
1517

16-
import { SvgCheckCircle1 } from '../../icons/v2';
17-
import { theme } from '../../style';
1818
import { Input } from '../common/Input';
1919
import { useFormat } from '../spreadsheet/useFormat';
2020
import { useSheetValue } from '../spreadsheet/useSheetValue';
@@ -133,11 +133,9 @@ export function ReconcileMenu({
133133
});
134134
const format = useFormat();
135135
const [inputValue, setInputValue] = useState<string | null>(null);
136-
const [inputFocused, setInputFocused] = useState(false);
137136

138137
function onSubmit() {
139138
if (inputValue === '') {
140-
setInputFocused(true);
141139
return;
142140
}
143141

@@ -162,7 +160,6 @@ export function ReconcileMenu({
162160
defaultValue={format(clearedBalance, 'financial')}
163161
onChangeValue={setInputValue}
164162
style={{ margin: '7px 0' }}
165-
focused={inputFocused}
166163
onEnter={onSubmit}
167164
/>
168165
</InitialFocus>

packages/desktop-client/src/components/common/Input.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,12 @@ import React, {
22
type InputHTMLAttributes,
33
type KeyboardEvent,
44
type Ref,
5-
useRef,
65
} from 'react';
76

8-
import { styles } from '@actual-app/components/styles';
7+
import { styles, type CSSProperties } from '@actual-app/components/styles';
8+
import { theme } from '@actual-app/components/theme';
99
import { css, cx } from '@emotion/css';
1010

11-
import { useMergedRefs } from '../../hooks/useMergedRefs';
12-
import { useProperFocus } from '../../hooks/useProperFocus';
13-
import { theme, type CSSProperties } from '../../style';
14-
1511
export const defaultInputStyle = {
1612
outline: 0,
1713
backgroundColor: theme.tableBackground,
@@ -29,7 +25,6 @@ type InputProps = InputHTMLAttributes<HTMLInputElement> & {
2925
onEscape?: (event: KeyboardEvent<HTMLInputElement>) => void;
3026
onChangeValue?: (newValue: string) => void;
3127
onUpdate?: (newValue: string) => void;
32-
focused?: boolean;
3328
};
3429

3530
export function Input({
@@ -39,18 +34,12 @@ export function Input({
3934
onEscape,
4035
onChangeValue,
4136
onUpdate,
42-
focused,
4337
className,
4438
...nativeProps
4539
}: InputProps) {
46-
const ref = useRef<HTMLInputElement>(null);
47-
useProperFocus(ref, focused);
48-
49-
const mergedRef = useMergedRefs<HTMLInputElement>(ref, inputRef);
50-
5140
return (
5241
<input
53-
ref={mergedRef}
42+
ref={inputRef}
5443
className={cx(
5544
css(
5645
defaultInputStyle,

packages/desktop-client/src/components/common/InputWithContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type InputWithContentProps = ComponentProps<typeof Input> & {
1313
focusStyle?: CSSProperties;
1414
style?: CSSProperties;
1515
getStyle?: (focused: boolean) => CSSProperties;
16+
focused?: boolean;
1617
};
1718
export function InputWithContent({
1819
leftContent,
@@ -43,7 +44,6 @@ export function InputWithContent({
4344
{leftContent}
4445
<Input
4546
{...props}
46-
focused={focused}
4747
style={{
4848
width: '100%',
4949
...inputStyle,

packages/desktop-client/src/components/common/Modal.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ export function ModalTitle({
422422
textAlign: 'center',
423423
...style,
424424
}}
425-
focused={isEditing}
426425
defaultValue={title}
427426
onUpdate={_onTitleUpdate}
428427
onKeyDown={e => {

packages/desktop-client/src/components/modals/EditFieldModal.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import React, {
77
import { useTranslation } from 'react-i18next';
88

99
import { Button } from '@actual-app/components/button';
10+
import { theme } from '@actual-app/components/theme';
1011
import { View } from '@actual-app/components/view';
1112
import { parseISO, format as formatDate, parse as parseDate } from 'date-fns';
1213

@@ -15,7 +16,6 @@ import { currentDay, dayFromDate } from 'loot-core/shared/months';
1516
import { amountToInteger } from 'loot-core/shared/util';
1617

1718
import { useDateFormat } from '../../hooks/useDateFormat';
18-
import { theme } from '../../style';
1919
import { Input } from '../common/Input';
2020
import { Modal, ModalCloseButton, ModalHeader } from '../common/Modal';
2121
import { SectionLabel } from '../forms';
@@ -82,7 +82,6 @@ export function EditFieldModal({
8282
<DateSelect
8383
value={formatDate(parseISO(today), dateFormat)}
8484
dateFormat={dateFormat}
85-
focused={true}
8685
embedded={true}
8786
onUpdate={() => {}}
8887
onSelect={date => {
@@ -205,7 +204,6 @@ export function EditFieldModal({
205204
<Input
206205
inputRef={noteInputRef}
207206
autoFocus
208-
focused={true}
209207
onEnter={e => {
210208
onSelectNote(e.currentTarget.value, noteAmend);
211209
close();
@@ -220,7 +218,6 @@ export function EditFieldModal({
220218
label = t('Amount');
221219
editor = ({ close }) => (
222220
<Input
223-
focused={true}
224221
onEnter={e => {
225222
onSelect(e.currentTarget.value);
226223
close();

packages/desktop-client/src/components/select/DateSelect.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import React, {
1313
} from 'react';
1414

1515
import { Popover } from '@actual-app/components/popover';
16-
import { styles } from '@actual-app/components/styles';
16+
import { styles, type CSSProperties } from '@actual-app/components/styles';
17+
import { theme } from '@actual-app/components/theme';
1718
import { View } from '@actual-app/components/view';
1819
import { css } from '@emotion/css';
1920
import { parse, parseISO, format, subDays, addDays, isValid } from 'date-fns';
@@ -31,7 +32,6 @@ import {
3132

3233
import { useLocale } from '../../hooks/useLocale';
3334
import { useSyncedPref } from '../../hooks/useSyncedPref';
34-
import { theme, type CSSProperties } from '../../style';
3535
import { Input } from '../common/Input';
3636

3737
import DateSelectLeft from './DateSelect.left.png';
@@ -223,7 +223,6 @@ type DateSelectProps = {
223223
isOpen?: boolean;
224224
embedded?: boolean;
225225
dateFormat: string;
226-
focused?: boolean;
227226
openOnFocus?: boolean;
228227
inputRef?: MutableRefObject<HTMLInputElement>;
229228
shouldSaveFromKey?: (e: KeyboardEvent<HTMLInputElement>) => boolean;
@@ -240,7 +239,6 @@ export function DateSelect({
240239
isOpen,
241240
embedded,
242241
dateFormat = 'yyyy-MM-dd',
243-
focused,
244242
openOnFocus = true,
245243
inputRef: originalInputRef,
246244
shouldSaveFromKey = defaultShouldSaveFromKey,
@@ -391,7 +389,6 @@ export function DateSelect({
391389
<View {...containerProps}>
392390
<Input
393391
id={id}
394-
focused={focused}
395392
{...inputProps}
396393
inputRef={inputRef}
397394
value={value}

packages/desktop-client/src/components/util/AmountInput.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ import React, {
1111
import { useTranslation } from 'react-i18next';
1212

1313
import { Button } from '@actual-app/components/button';
14+
import { SvgAdd, SvgSubtract } from '@actual-app/components/icons/v1';
15+
import { theme } from '@actual-app/components/theme';
1416
import { View } from '@actual-app/components/view';
1517

1618
import { evalArithmetic } from 'loot-core/shared/arithmetic';
1719
import { amountToInteger, appendDecimals } from 'loot-core/shared/util';
1820

1921
import { useMergedRefs } from '../../hooks/useMergedRefs';
2022
import { useSyncedPref } from '../../hooks/useSyncedPref';
21-
import { SvgAdd, SvgSubtract } from '../../icons/v1';
22-
import { theme } from '../../style';
2323
import { InputWithContent } from '../common/InputWithContent';
2424
import { useFormat } from '../spreadsheet/useFormat';
2525

@@ -138,7 +138,6 @@ export function AmountInput({
138138
}
139139
value={value}
140140
disabled={disabled}
141-
focused={focused}
142141
style={{ flex: 1, alignItems: 'stretch', ...style }}
143142
inputStyle={inputStyle}
144143
onKeyUp={e => {

packages/desktop-client/src/components/util/PercentInput.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ export function PercentInput({
108108
inputMode="decimal"
109109
value={value}
110110
disabled={disabled}
111-
focused={focused}
112111
style={{ flex: 1, alignItems: 'stretch', ...style }}
113112
onKeyUp={e => {
114113
if (e.key === 'Enter') {

upcoming-release-notes/4557.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
category: Maintenance
3+
authors: [MatissJanis]
4+
---
5+
6+
Removing `focused` prop (that does nothing) from common `Input` component.

0 commit comments

Comments
 (0)