A local-first personal finance app
Larger mobile autocomplete fonts and paddings (#1900)
Joel Jeremy Marquez5d1f2d48ae36
diff --git a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-from-accounts-id-page-1-chromium-linux.png b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-from-accounts-id-page-1-chromium-linux.pngindex fd6ae26237..c06b43e4a8 100644Binary files a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-from-accounts-id-page-1-chromium-linux.png and b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-from-accounts-id-page-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-from-accounts-id-page-2-chromium-linux.png b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-from-accounts-id-page-2-chromium-linux.pngindex 44f47e74e9..965e6a84b2 100644Binary files a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-from-accounts-id-page-2-chromium-linux.png and b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-from-accounts-id-page-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-1-chromium-linux.png b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-1-chromium-linux.pngindex 90fef006b7..c5647b3882 100644Binary files a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-1-chromium-linux.png and b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-1-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-2-chromium-linux.png b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-2-chromium-linux.pngindex ba09390fcd..efcb130922 100644Binary files a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-2-chromium-linux.png and b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-2-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-3-chromium-linux.png b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-3-chromium-linux.pngindex 8c390cc6e7..6b193821e3 100644Binary files a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-3-chromium-linux.png and b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-3-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-4-chromium-linux.png b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-4-chromium-linux.pngindex 6d4b9adb07..9d023dffd9 100644Binary files a/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-4-chromium-linux.png and b/packages/desktop-client/e2e/mobile.test.js-snapshots/Mobile-creates-a-transaction-via-footer-button-4-chromium-linux.png differdiff --git a/packages/desktop-client/e2e/transactions.test.js b/packages/desktop-client/e2e/transactions.test.jsindex 0fc9070ef1..2d2f40dbfc 100644--- a/packages/desktop-client/e2e/transactions.test.js+++ b/packages/desktop-client/e2e/transactions.test.js@@ -63,7 +63,7 @@ test.describe('Transactions', () => {await expect(autocomplete).toMatchThemeScreenshots();// Select the active item- await page.getByRole('button', { name: 'Clothing' }).click();+ await page.getByTestId('Clothing-category-item').click();await filterTooltip.applyButton.click();// Assert that there are only clothing transactionsdiff --git a/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsxindex dbd7f67e7e..d23aec146e 100644--- a/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx+++ b/packages/desktop-client/src/components/autocomplete/AccountAutocomplete.tsx@@ -1,10 +1,11 @@-import React, { type ComponentProps } from 'react';+import React, { Fragment, type ComponentProps, type ReactNode } from 'react';import { css } from 'glamor';import { useCachedAccounts } from 'loot-core/src/client/data-hooks/accounts';+import { type AccountEntity } from 'loot-core/src/types/models';-import { theme } from '../../style';+import { type CSSProperties, theme } from '../../style';import View from '../common/View';import Autocomplete from './Autocomplete';@@ -14,7 +15,8 @@ function AccountList({getItemProps,highlightedIndex,embedded,- groupHeaderStyle,+ renderAccountItemGroupHeader = defaultRenderAccountItemGroupHeader,+ renderAccountItem = defaultRenderAccountItem,}) {let lastItem = null;@@ -45,62 +47,18 @@ function AccountList({return [showGroup ? (- <div- key={group}- style={{- color: theme.menuAutoCompleteTextHeader,- padding: '4px 9px',- ...groupHeaderStyle,- }}- data-testid="account-item-group"- >- {group}- </div>+ <Fragment key={group}>+ {renderAccountItemGroupHeader({ title: group })}+ </Fragment>) : null,- <div- // List each account up to a max- {...(getItemProps ? getItemProps({ item }) : null)}- // Downshift calls `setTimeout(..., 250)` in the `onMouseMove`- // event handler they set on this element. When this code runs- // in WebKit on touch-enabled devices, taps on this element end- // up not triggering the `onClick` event (and therefore delaying- // response to user input) until after the `setTimeout` callback- // finishes executing. This is caused by content observation code- // that implements various strategies to prevent the user from- // accidentally clicking content that changed as a result of code- // run in the `onMouseMove` event.- //- // Long story short, we don't want any delay here between the user- // tapping and the resulting action being performed. It turns out- // there's some "fast path" logic that can be triggered in various- // ways to force WebKit to bail on the content observation process.- // One of those ways is setting `role="button"` (or a number of- // other aria roles) on the element, which is what we're doing here.- //- // ref:- // * https://github.com/WebKit/WebKit/blob/447d90b0c52b2951a69df78f06bb5e6b10262f4b/LayoutTests/fast/events/touch/ios/content-observation/400ms-hover-intent.html- // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebCore/page/ios/ContentChangeObserver.cpp- // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#L783- role="button"- key={item.id}- className={`${css([- {- backgroundColor:- highlightedIndex === idx- ? theme.menuAutoCompleteBackgroundHover- : 'transparent',- padding: 4,- paddingLeft: 20,- borderRadius: embedded ? 4 : 0,- },- ])}`}- data-testid={- 'account-item' +- (highlightedIndex === idx ? '-highlighted' : '')- }- >- {item.name}- </div>,+ <Fragment key={item.id}>+ {renderAccountItem({+ ...(getItemProps ? getItemProps({ item }) : null),+ item,+ highlighted: highlightedIndex === idx,+ embedded,+ })}+ </Fragment>,];})}</View>@@ -108,20 +66,24 @@ function AccountList({);}-type AutoCompleteProps = {+type AccountAutoCompleteProps = {embedded?: boolean;includeClosedAccounts: boolean;- groupHeaderStyle?: boolean;+ renderAccountItemGroupHeader?: (+ props: AccountItemGroupHeaderProps,+ ) => ReactNode;+ renderAccountItem?: (props: AccountItemProps) => ReactNode;closeOnBlur?: boolean;} & ComponentProps<typeof Autocomplete>;export default function AccountAutocomplete({embedded,includeClosedAccounts = true,- groupHeaderStyle,+ renderAccountItemGroupHeader,+ renderAccountItem,closeOnBlur,...props-}: AutoCompleteProps) {+}: AccountAutoCompleteProps) {let accounts = useCachedAccounts() || [];//remove closed accounts if needed@@ -151,10 +113,107 @@ export default function AccountAutocomplete({getItemProps={getItemProps}highlightedIndex={highlightedIndex}embedded={embedded}- groupHeaderStyle={groupHeaderStyle}+ renderAccountItemGroupHeader={renderAccountItemGroupHeader}+ renderAccountItem={renderAccountItem}/>)}{...props}/>);}++type AccountItemGroupHeaderProps = {+ title: string;+ style?: CSSProperties;+};++export function AccountItemGroupHeader({+ title,+ style,+ ...props+}: AccountItemGroupHeaderProps) {+ return (+ <div+ style={{+ color: theme.menuAutoCompleteTextHeader,+ padding: '4px 9px',+ ...style,+ }}+ data-testid={`${title}-account-item-group`}+ {...props}+ >+ {title}+ </div>+ );+}++function defaultRenderAccountItemGroupHeader(+ props: AccountItemGroupHeaderProps,+): ReactNode {+ return <AccountItemGroupHeader {...props} />;+}++type AccountItemProps = {+ item: AccountEntity;+ className?: string;+ style?: CSSProperties;+ highlighted?: boolean;+ embedded?: boolean;+};++export function AccountItem({+ item,+ className,+ highlighted,+ embedded,+ ...props+}: AccountItemProps) {+ return (+ <div+ // List each account up to a max+ // Downshift calls `setTimeout(..., 250)` in the `onMouseMove`+ // event handler they set on this element. When this code runs+ // in WebKit on touch-enabled devices, taps on this element end+ // up not triggering the `onClick` event (and therefore delaying+ // response to user input) until after the `setTimeout` callback+ // finishes executing. This is caused by content observation code+ // that implements various strategies to prevent the user from+ // accidentally clicking content that changed as a result of code+ // run in the `onMouseMove` event.+ //+ // Long story short, we don't want any delay here between the user+ // tapping and the resulting action being performed. It turns out+ // there's some "fast path" logic that can be triggered in various+ // ways to force WebKit to bail on the content observation process.+ // One of those ways is setting `role="button"` (or a number of+ // other aria roles) on the element, which is what we're doing here.+ //+ // ref:+ // * https://github.com/WebKit/WebKit/blob/447d90b0c52b2951a69df78f06bb5e6b10262f4b/LayoutTests/fast/events/touch/ios/content-observation/400ms-hover-intent.html+ // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebCore/page/ios/ContentChangeObserver.cpp+ // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#L783+ role="button"+ className={`${className} ${css([+ {+ backgroundColor: highlighted+ ? embedded+ ? theme.menuItemBackgroundHover+ : theme.menuAutoCompleteBackgroundHover+ : 'transparent',+ padding: 4,+ paddingLeft: 20,+ borderRadius: embedded ? 4 : 0,+ },+ ])}`}+ data-testid={`${item.name}-account-item`}+ data-highlighted={highlighted || undefined}+ {...props}+ >+ {item.name}+ </div>+ );+}++function defaultRenderAccountItem(props: AccountItemProps): ReactNode {+ return <AccountItem {...props} />;+}diff --git a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsxindex 35266b806a..1ed1009f97 100644--- a/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx+++ b/packages/desktop-client/src/components/autocomplete/CategoryAutocomplete.tsx@@ -3,7 +3,8 @@ import React, {Fragment,useMemo,type ReactNode,- type CSSProperties,+ type SVGProps,+ type ComponentType,} from 'react';import { css } from 'glamor';@@ -14,7 +15,7 @@ import {} from 'loot-core/src/types/models';import Split from '../../icons/v0/Split';-import { theme } from '../../style';+import { type CSSProperties, theme } from '../../style';import Text from '../common/Text';import View from '../common/View';@@ -26,7 +27,13 @@ export type CategoryListProps = {highlightedIndex: number;embedded: boolean;footer?: ReactNode;- groupHeaderStyle?: object;+ renderSplitTransactionButton?: (+ props: SplitTransactionButtonProps,+ ) => ReactNode;+ renderCategoryItemGroupHeader?: (+ props: CategoryItemGroupHeaderProps,+ ) => ReactNode;+ renderCategoryItem?: (props: CategoryItemProps) => ReactNode;};function CategoryList({items,@@ -34,7 +41,9 @@ function CategoryList({highlightedIndex,embedded,footer,- groupHeaderStyle,+ renderSplitTransactionButton = defaultRenderSplitTransactionButton,+ renderCategoryItemGroupHeader = defaultRenderCategoryItemGroupHeader,+ renderCategoryItem = defaultRenderCategoryItem,}: CategoryListProps) {let lastGroup = null;@@ -49,57 +58,12 @@ function CategoryList({>{items.map((item, idx) => {if (item.id === 'split') {- return (- <View- key="split"- {...(getItemProps ? getItemProps({ item }) : null)}- // Downshift calls `setTimeout(..., 250)` in the `onMouseMove`- // event handler they set on this element. When this code runs- // in WebKit on touch-enabled devices, taps on this element end- // up not triggering the `onClick` event (and therefore delaying- // response to user input) until after the `setTimeout` callback- // finishes executing. This is caused by content observation code- // that implements various strategies to prevent the user from- // accidentally clicking content that changed as a result of code- // run in the `onMouseMove` event.- //- // Long story short, we don't want any delay here between the user- // tapping and the resulting action being performed. It turns out- // there's some "fast path" logic that can be triggered in various- // ways to force WebKit to bail on the content observation process.- // One of those ways is setting `role="button"` (or a number of- // other aria roles) on the element, which is what we're doing here.- //- // ref:- // * https://github.com/WebKit/WebKit/blob/447d90b0c52b2951a69df78f06bb5e6b10262f4b/LayoutTests/fast/events/touch/ios/content-observation/400ms-hover-intent.html- // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebCore/page/ios/ContentChangeObserver.cpp- // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#L783- role="button"- style={{- backgroundColor:- highlightedIndex === idx- ? theme.menuAutoCompleteBackgroundHover- : 'transparent',- borderRadius: embedded ? 4 : 0,- flexShrink: 0,- flexDirection: 'row',- alignItems: 'center',- fontSize: 11,- fontWeight: 500,- color: theme.noticeTextMenu,- padding: '6px 8px',- ':active': {- backgroundColor: 'rgba(100, 100, 100, .25)',- },- }}- data-testid="split-transaction-button"- >- <Text style={{ lineHeight: 0 }}>- <Split width={10} height={10} style={{ marginRight: 5 }} />- </Text>- Split Transaction- </View>- );+ return renderSplitTransactionButton({+ key: 'split',+ ...(getItemProps ? getItemProps({ item }) : null),+ highlighted: highlightedIndex === idx,+ embedded,+ });}const showGroup = item.cat_group !== lastGroup;@@ -107,39 +71,20 @@ function CategoryList({return (<Fragment key={item.id}>{showGroup && (- <div- style={{- color: theme.menuAutoCompleteTextHeader,- padding: '4px 9px',- ...groupHeaderStyle,- }}- data-testid="category-item-group"- >- {`${item.group?.name}`}- </div>+ <Fragment key={item.group?.name}>+ {renderCategoryItemGroupHeader({+ title: item.group?.name,+ })}+ </Fragment>)}- <div- {...(getItemProps ? getItemProps({ item }) : null)}- // See comment above.- role="button"- className={`${css([- {- backgroundColor:- highlightedIndex === idx- ? theme.menuAutoCompleteBackgroundHover- : 'transparent',- padding: 4,- paddingLeft: 20,- borderRadius: embedded ? 4 : 0,- },- ])}`}- data-testid={- 'category-item' +- (highlightedIndex === idx ? '-highlighted' : '')- }- >- {item.name}- </div>+ <Fragment key={item.id}>+ {renderCategoryItem({+ ...(getItemProps ? getItemProps({ item }) : null),+ item,+ highlighted: highlightedIndex === idx,+ embedded,+ })}+ </Fragment></Fragment>);})}@@ -152,7 +97,13 @@ function CategoryList({type CategoryAutocompleteProps = ComponentProps<typeof Autocomplete> & {categoryGroups: Array<CategoryGroupEntity>;showSplitOption?: boolean;- groupHeaderStyle?: CSSProperties;+ renderSplitTransactionButton?: (+ props: SplitTransactionButtonProps,+ ) => ReactNode;+ renderCategoryItemGroupHeader?: (+ props: CategoryItemGroupHeaderProps,+ ) => ReactNode;+ renderCategoryItem?: (props: CategoryItemProps) => ReactNode;};export default function CategoryAutocomplete({@@ -160,7 +111,9 @@ export default function CategoryAutocomplete({showSplitOption,embedded,closeOnBlur,- groupHeaderStyle,+ renderSplitTransactionButton,+ renderCategoryItemGroupHeader,+ renderCategoryItem,...props}: CategoryAutocompleteProps) {let categorySuggestions: Array<@@ -211,10 +164,166 @@ export default function CategoryAutocomplete({embedded={embedded}getItemProps={getItemProps}highlightedIndex={highlightedIndex}- groupHeaderStyle={groupHeaderStyle}+ renderSplitTransactionButton={renderSplitTransactionButton}+ renderCategoryItemGroupHeader={renderCategoryItemGroupHeader}+ renderCategoryItem={renderCategoryItem}/>)}{...props}/>);}++type CategoryItemGroupHeaderProps = {+ title: string;+ style?: CSSProperties;+};++export function CategoryItemGroupHeader({+ title,+ style,+ ...props+}: CategoryItemGroupHeaderProps) {+ return (+ <div+ style={{+ color: theme.menuAutoCompleteTextHeader,+ padding: '4px 9px',+ ...style,+ }}+ data-testid={`${title}-category-item-group`}+ {...props}+ >+ {title}+ </div>+ );+}++function defaultRenderCategoryItemGroupHeader(+ props: CategoryItemGroupHeaderProps,+) {+ return <CategoryItemGroupHeader {...props} />;+}++type SplitTransactionButtonProps = {+ Icon?: ComponentType<SVGProps<SVGElement>>;+ highlighted?: boolean;+ embedded?: boolean;+ style?: CSSProperties;+};++// eslint-disable-next-line import/no-unused-modules+export function SplitTransactionButton({+ Icon,+ highlighted,+ embedded,+ style,+ ...props+}: SplitTransactionButtonProps) {+ return (+ <View+ // Downshift calls `setTimeout(..., 250)` in the `onMouseMove`+ // event handler they set on this element. When this code runs+ // in WebKit on touch-enabled devices, taps on this element end+ // up not triggering the `onClick` event (and therefore delaying+ // response to user input) until after the `setTimeout` callback+ // finishes executing. This is caused by content observation code+ // that implements various strategies to prevent the user from+ // accidentally clicking content that changed as a result of code+ // run in the `onMouseMove` event.+ //+ // Long story short, we don't want any delay here between the user+ // tapping and the resulting action being performed. It turns out+ // there's some "fast path" logic that can be triggered in various+ // ways to force WebKit to bail on the content observation process.+ // One of those ways is setting `role="button"` (or a number of+ // other aria roles) on the element, which is what we're doing here.+ //+ // ref:+ // * https://github.com/WebKit/WebKit/blob/447d90b0c52b2951a69df78f06bb5e6b10262f4b/LayoutTests/fast/events/touch/ios/content-observation/400ms-hover-intent.html+ // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebCore/page/ios/ContentChangeObserver.cpp+ // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#L783+ role="button"+ style={{+ backgroundColor: highlighted+ ? embedded+ ? theme.menuItemBackgroundHover+ : theme.menuAutoCompleteBackgroundHover+ : 'transparent',+ borderRadius: embedded ? 4 : 0,+ flexShrink: 0,+ flexDirection: 'row',+ alignItems: 'center',+ fontSize: 11,+ fontWeight: 500,+ color: theme.noticeTextMenu,+ padding: '6px 8px',+ ':active': {+ backgroundColor: 'rgba(100, 100, 100, .25)',+ },+ ...style,+ }}+ data-testid="split-transaction-button"+ {...props}+ >+ <Text style={{ lineHeight: 0 }}>+ {Icon ? (+ <Icon style={{ marginRight: 5 }} />+ ) : (+ <Split width={10} height={10} style={{ marginRight: 5 }} />+ )}+ </Text>+ Split Transaction+ </View>+ );+}++function defaultRenderSplitTransactionButton(+ props: SplitTransactionButtonProps,+) {+ return <SplitTransactionButton {...props} />;+}++type CategoryItemProps = {+ item: CategoryEntity & { group?: CategoryGroupEntity };+ className?: string;+ style?: CSSProperties;+ highlighted?: boolean;+ embedded?: boolean;+};++export function CategoryItem({+ item,+ className,+ highlighted,+ embedded,+ ...props+}: CategoryItemProps) {+ return (+ <div+ // See comment above.+ role="button"+ className={`${className} ${css([+ {+ backgroundColor: highlighted+ ? embedded+ ? theme.menuItemBackgroundHover+ : theme.menuAutoCompleteBackgroundHover+ : 'transparent',+ padding: 4,+ paddingLeft: 20,+ borderRadius: embedded ? 4 : 0,+ },+ ])}`}+ data-testid={`${item.name}-category-item`}+ data-highlighted={highlighted || undefined}+ {...props}+ >+ {item.name}+ </div>+ );+}++function defaultRenderCategoryItem(props: CategoryItemProps) {+ return <CategoryItem {...props} />;+}diff --git a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsxindex a1ff9db998..708d9dcb22 100644--- a/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx+++ b/packages/desktop-client/src/components/autocomplete/PayeeAutocomplete.tsx@@ -3,7 +3,9 @@ import React, {useState,useMemo,type ComponentProps,- type CSSProperties,+ type ReactNode,+ type ComponentType,+ type SVGProps,} from 'react';import { useDispatch } from 'react-redux';@@ -19,8 +21,7 @@ import {} from 'loot-core/src/types/models';import Add from '../../icons/v1/Add';-import { useResponsive } from '../../ResponsiveProvider';-import { theme } from '../../style';+import { type CSSProperties, theme } from '../../style';import Button from '../common/Button';import View from '../common/View';@@ -61,10 +62,11 @@ function PayeeList({highlightedIndex,embedded,inputValue,- groupHeaderStyle,+ renderCreatePayeeButton = defaultRenderCreatePayeeButton,+ renderPayeeItemGroupHeader = defaultRenderPayeeItemGroupHeader,+ renderPayeeItem = defaultRenderPayeeItem,footer,}) {- const { isNarrowWidth } = useResponsive();let isFiltered = items.filtered;let createNew = null;items = [...items];@@ -90,40 +92,13 @@ function PayeeList({...(!embedded && { maxHeight: 175 }),}}>- {createNew && (- <View- {...(getItemProps ? getItemProps({ item: createNew }) : null)}- style={{- flexShrink: 0,- padding: '6px 9px',- backgroundColor:- highlightedIndex === 0- ? theme.menuAutoCompleteBackgroundHover- : 'transparent',- borderRadius: embedded ? 4 : 0,- ':active': {- backgroundColor: 'rgba(100, 100, 100, .25)',- },- }}- >- <View- style={{- display: 'block',- color: theme.noticeTextMenu,- borderRadius: 4,- fontSize: isNarrowWidth ? 'inherit' : 11,- fontWeight: 500,- }}- >- <Add- width={8}- height={8}- style={{ marginRight: 5, display: 'inline-block' }}- />- Create Payee “{inputValue}”- </View>- </View>- )}+ {createNew &&+ renderCreatePayeeButton({+ ...(getItemProps ? getItemProps({ item: createNew }) : null),+ payeeName: inputValue,+ highlighted: highlightedIndex === 0,+ embedded,+ })}{items.map((item, idx) => {let type = item.transfer_acct ? 'account' : 'payee';@@ -139,62 +114,23 @@ function PayeeList({return (<Fragment key={item.id}>{title && (- <div- key={'title-' + idx}- style={{- color: theme.menuAutoCompleteTextHeader,- padding: '4px 9px',- ...groupHeaderStyle,- }}- >- {title}- </div>+ <Fragment key={`title-${idx}`}>+ {renderPayeeItemGroupHeader({ title })}+ </Fragment>)}-- <div- {...(getItemProps ? getItemProps({ item }) : null)}- // Downshift calls `setTimeout(..., 250)` in the `onMouseMove`- // event handler they set on this element. When this code runs- // in WebKit on touch-enabled devices, taps on this element end- // up not triggering the `onClick` event (and therefore delaying- // response to user input) until after the `setTimeout` callback- // finishes executing. This is caused by content observation code- // that implements various strategies to prevent the user from- // accidentally clicking content that changed as a result of code- // run in the `onMouseMove` event.- //- // Long story short, we don't want any delay here between the user- // tapping and the resulting action being performed. It turns out- // there's some "fast path" logic that can be triggered in various- // ways to force WebKit to bail on the content observation process.- // One of those ways is setting `role="button"` (or a number of- // other aria roles) on the element, which is what we're doing here.- //- // ref:- // * https://github.com/WebKit/WebKit/blob/447d90b0c52b2951a69df78f06bb5e6b10262f4b/LayoutTests/fast/events/touch/ios/content-observation/400ms-hover-intent.html- // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebCore/page/ios/ContentChangeObserver.cpp- // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#L783- role="button"- key={item.id}- className={`${css([- {- backgroundColor:- highlightedIndex === idx + offset- ? theme.menuAutoCompleteBackgroundHover- : 'transparent',- borderRadius: embedded ? 4 : 0,- padding: 4,- paddingLeft: 20,- },- ])}`}- >- {item.name}- </div>+ <Fragment key={item.id}>+ {renderPayeeItem({+ ...(getItemProps ? getItemProps({ item }) : null),+ item,+ highlighted: highlightedIndex === idx + offset,+ embedded,+ })}+ </Fragment>{showMoreMessage && (<divstyle={{- fontSize: isNarrowWidth ? 'inherit' : 11,+ fontSize: 11,padding: 5,color: theme.pageTextLight,textAlign: 'center',@@ -223,7 +159,9 @@ type PayeeAutocompleteProps = {onUpdate?: (value: string) => void;onSelect?: (value: string) => void;onManagePayees: () => void;- groupHeaderStyle: CSSProperties;+ renderCreatePayeeButton?: (props: CreatePayeeButtonProps) => ReactNode;+ renderPayeeItemGroupHeader?: (props: PayeeItemGroupHeaderProps) => ReactNode;+ renderPayeeItem?: (props: PayeeItemProps) => ReactNode;accounts?: AccountEntity[];payees?: PayeeEntity[];};@@ -239,7 +177,9 @@ export default function PayeeAutocomplete({onUpdate,onSelect,onManagePayees,- groupHeaderStyle,+ renderCreatePayeeButton = defaultRenderCreatePayeeButton,+ renderPayeeItemGroupHeader = defaultRenderPayeeItemGroupHeader,+ renderPayeeItem = defaultRenderPayeeItem,accounts,payees,...props@@ -386,7 +326,9 @@ export default function PayeeAutocomplete({highlightedIndex={highlightedIndex}inputValue={inputValue}embedded={embedded}- groupHeaderStyle={groupHeaderStyle}+ renderCreatePayeeButton={renderCreatePayeeButton}+ renderPayeeItemGroupHeader={renderPayeeItemGroupHeader}+ renderPayeeItem={renderPayeeItem}footer={<AutocompleteFooter embedded={embedded}>{showMakeTransfer && (@@ -414,3 +356,157 @@ export default function PayeeAutocomplete({/>);}++type CreatePayeeButtonProps = {+ Icon?: ComponentType<SVGProps<SVGElement>>;+ payeeName: string;+ highlighted?: boolean;+ embedded?: boolean;+ style?: CSSProperties;+};++export function CreatePayeeButton({+ Icon,+ payeeName,+ highlighted,+ embedded,+ style,+ ...props+}: CreatePayeeButtonProps) {+ return (+ <View+ data-testid="create-payee-button"+ style={{+ display: 'block',+ flexShrink: 0,+ color: embedded ? theme.menuItemText : theme.noticeTextMenu,+ borderRadius: embedded ? 4 : 0,+ fontSize: 11,+ fontWeight: 500,+ padding: '6px 9px',+ backgroundColor: highlighted+ ? embedded+ ? theme.menuItemBackgroundHover+ : theme.menuAutoCompleteBackgroundHover+ : 'transparent',+ ':active': {+ backgroundColor: 'rgba(100, 100, 100, .25)',+ },+ ...style,+ }}+ {...props}+ >+ {Icon ? (+ <Icon style={{ marginRight: 5, display: 'inline-block' }} />+ ) : (+ <Add+ width={8}+ height={8}+ style={{ marginRight: 5, display: 'inline-block' }}+ />+ )}+ Create Payee “{payeeName}”+ </View>+ );+}++function defaultRenderCreatePayeeButton(+ props: CreatePayeeButtonProps,+): ReactNode {+ return <CreatePayeeButton {...props} />;+}++type PayeeItemGroupHeaderProps = {+ title: string;+ style?: CSSProperties;+};++export function PayeeItemGroupHeader({+ title,+ style,+ ...props+}: PayeeItemGroupHeaderProps) {+ return (+ <div+ style={{+ color: theme.menuAutoCompleteTextHeader,+ padding: '4px 9px',+ ...style,+ }}+ data-testid={`${title}-payee-item-group`}+ {...props}+ >+ {title}+ </div>+ );+}++function defaultRenderPayeeItemGroupHeader(+ props: PayeeItemGroupHeaderProps,+): ReactNode {+ return <PayeeItemGroupHeader {...props} />;+}++type PayeeItemProps = {+ item: PayeeEntity;+ className?: string;+ style?: CSSProperties;+ highlighted?: boolean;+ embedded?: boolean;+};++export function PayeeItem({+ item,+ className,+ highlighted,+ embedded,+ ...props+}: PayeeItemProps) {+ return (+ <div+ // Downshift calls `setTimeout(..., 250)` in the `onMouseMove`+ // event handler they set on this element. When this code runs+ // in WebKit on touch-enabled devices, taps on this element end+ // up not triggering the `onClick` event (and therefore delaying+ // response to user input) until after the `setTimeout` callback+ // finishes executing. This is caused by content observation code+ // that implements various strategies to prevent the user from+ // accidentally clicking content that changed as a result of code+ // run in the `onMouseMove` event.+ //+ // Long story short, we don't want any delay here between the user+ // tapping and the resulting action being performed. It turns out+ // there's some "fast path" logic that can be triggered in various+ // ways to force WebKit to bail on the content observation process.+ // One of those ways is setting `role="button"` (or a number of+ // other aria roles) on the element, which is what we're doing here.+ //+ // ref:+ // * https://github.com/WebKit/WebKit/blob/447d90b0c52b2951a69df78f06bb5e6b10262f4b/LayoutTests/fast/events/touch/ios/content-observation/400ms-hover-intent.html+ // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebCore/page/ios/ContentChangeObserver.cpp+ // * https://github.com/WebKit/WebKit/blob/58956cf59ba01267644b5e8fe766efa7aa6f0c5c/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm#L783+ role="button"+ className={`${className} ${css([+ {+ backgroundColor: highlighted+ ? embedded+ ? theme.menuItemBackgroundHover+ : theme.menuAutoCompleteBackgroundHover+ : 'transparent',+ borderRadius: embedded ? 4 : 0,+ padding: 4,+ paddingLeft: 20,+ },+ ])}`}+ data-testid={`${item.name}-payee-item`}+ data-highlighted={highlighted || undefined}+ {...props}+ >+ {item.name}+ </div>+ );+}++function defaultRenderPayeeItem(props: PayeeItemProps): ReactNode {+ return <PayeeItem {...props} />;+}diff --git a/packages/desktop-client/src/components/autocomplete/SavedFilterAutocomplete.tsx b/packages/desktop-client/src/components/autocomplete/SavedFilterAutocomplete.tsxindex 71646b65f5..347db08263 100644--- a/packages/desktop-client/src/components/autocomplete/SavedFilterAutocomplete.tsx+++ b/packages/desktop-client/src/components/autocomplete/SavedFilterAutocomplete.tsx@@ -43,9 +43,8 @@ function FilterList({paddingLeft: 20,borderRadius: embedded ? 4 : 0,}}- data-testid={- 'filter-item' + (highlightedIndex === idx ? '-highlighted' : '')- }+ data-testid={`${item.name}-filter-item`}+ data-highlighted={highlightedIndex === idx || undefined}>{item.name}</div>,diff --git a/packages/desktop-client/src/components/mobile/MobileNavTabs.tsx b/packages/desktop-client/src/components/mobile/MobileNavTabs.tsxindex 454351e11c..aa7a68792e 100644--- a/packages/desktop-client/src/components/mobile/MobileNavTabs.tsx+++ b/packages/desktop-client/src/components/mobile/MobileNavTabs.tsx@@ -35,43 +35,43 @@ export default function MobileNavTabs() {name: 'Budget',path: '/budget',style: navTabStyle,- icon: Wallet,+ Icon: Wallet,},{name: 'Transaction',path: '/transactions/new',style: navTabStyle,- icon: Add,+ Icon: Add,},{name: 'Accounts',path: '/accounts',style: navTabStyle,- icon: PiggyBank,+ Icon: PiggyBank,},{name: 'Schedules (Soon)',path: '/schedules/soon',style: navTabStyle,- icon: Calendar,+ Icon: Calendar,},{name: 'Payees (Soon)',path: '/payees/soon',style: navTabStyle,- icon: StoreFront,+ Icon: StoreFront,},{name: 'Rules (Soon)',path: '/rules/soon',style: navTabStyle,- icon: Tuning,+ Icon: Tuning,},{name: 'Settings',path: '/settings',style: navTabStyle,- icon: Cog,+ Icon: Cog,},].map(tab => <NavTab key={tab.path} {...tab} />);@@ -206,11 +206,11 @@ type NavTabIconProps = {type NavTabProps = {name: string;path: string;- icon: ComponentType<NavTabIconProps>;+ Icon: ComponentType<NavTabIconProps>;style?: CSSProperties;};-function NavTab({ icon: TabIcon, name, path, style }: NavTabProps) {+function NavTab({ Icon: TabIcon, name, path, style }: NavTabProps) {return (<NavLinkto={path}diff --git a/packages/desktop-client/src/components/modals/EditField.js b/packages/desktop-client/src/components/modals/EditField.jsindex e6f68be049..cc54d60bcf 100644--- a/packages/desktop-client/src/components/modals/EditField.js+++ b/packages/desktop-client/src/components/modals/EditField.js@@ -8,17 +8,32 @@ import { amountToInteger } from 'loot-core/src/shared/util';import { useActions } from '../../hooks/useActions';import useCategories from '../../hooks/useCategories';+import { Add } from '../../icons/v1';import { useResponsive } from '../../ResponsiveProvider';-import { theme } from '../../style';-import AccountAutocomplete from '../autocomplete/AccountAutocomplete';-import CategoryAutocomplete from '../autocomplete/CategoryAutocomplete';-import PayeeAutocomplete from '../autocomplete/PayeeAutocomplete';+import { styles, theme } from '../../style';+import AccountAutocomplete, {+ AccountItemGroupHeader,+ AccountItem,+} from '../autocomplete/AccountAutocomplete';+import CategoryAutocomplete, {+ CategoryItemGroupHeader,+ CategoryItem,+} from '../autocomplete/CategoryAutocomplete';+import PayeeAutocomplete, {+ CreatePayeeButton,+ PayeeItemGroupHeader,+ PayeeItem,+} from '../autocomplete/PayeeAutocomplete';import Input from '../common/Input';import Modal from '../common/Modal';import View from '../common/View';import { SectionLabel } from '../forms';import DateSelect from '../select/DateSelect';+function CreatePayeeIcon(props) {+ return <Add {...props} width={14} height={14} />;+}+export default function EditField({ modalProps, name, onSubmit }) {let dateFormat = useSelector(state => state.prefs.local.dateFormat || 'MM/dd/yyyy',@@ -41,9 +56,19 @@ export default function EditField({ modalProps, name, onSubmit }) {modalProps.onClose();}+ const itemStyle = {+ fontSize: 17,+ fontWeight: 400,+ paddingTop: 8,+ paddingBottom: 8,+ };+const { isNarrowWidth } = useResponsive();let label, editor, minWidth;- let inputStyle = { ':focus': { boxShadow: 0 } };+ let inputStyle = {+ ':focus': { boxShadow: 0 },+ ...(isNarrowWidth && itemStyle),+ };let autocompleteProps = {inputProps: { style: inputStyle },containerProps: { style: { height: isNarrowWidth ? '90vh' : 275 } },@@ -83,13 +108,28 @@ export default function EditField({ modalProps, name, onSubmit }) {onSelect(value);}}}- groupHeaderStyle={- isNarrowWidth- ? {- color: theme.tableTextLight,- }- : undefined- }+ renderAccountItemGroupHeader={props => (+ <AccountItemGroupHeader+ {...props}+ style={{+ ...styles.largeText,+ color: theme.menuItemTextHeader,+ paddingTop: 10,+ paddingBottom: 10,+ }}+ />+ )}+ renderAccountItem={props => (+ <AccountItem+ {...props}+ style={{+ ...itemStyle,+ color: theme.menuItemText,+ borderRadius: 0,+ borderTop: `1px solid ${theme.pillBorder}`,+ }}+ />+ )}{...autocompleteProps}/>);@@ -115,13 +155,35 @@ export default function EditField({ modalProps, name, onSubmit }) {onSelect(value);}}isCreatable- groupHeaderStyle={- isNarrowWidth- ? {- color: theme.tableTextLight,- }- : undefined- }+ renderCreatePayeeButton={props => (+ <CreatePayeeButton+ {...props}+ Icon={CreatePayeeIcon}+ style={itemStyle}+ />+ )}+ renderPayeeItemGroupHeader={props => (+ <PayeeItemGroupHeader+ {...props}+ style={{+ ...styles.largeText,+ color: theme.menuItemTextHeader,+ paddingTop: 10,+ paddingBottom: 10,+ }}+ />+ )}+ renderPayeeItem={props => (+ <PayeeItem+ {...props}+ style={{+ ...itemStyle,+ color: theme.menuItemText,+ borderRadius: 0,+ borderTop: `1px solid ${theme.pillBorder}`,+ }}+ />+ )}{...autocompleteProps}/>);@@ -152,13 +214,28 @@ export default function EditField({ modalProps, name, onSubmit }) {onSelect={value => {onSelect(value);}}- groupHeaderStyle={- isNarrowWidth- ? {- color: theme.tableTextLight,- }- : undefined- }+ renderCategoryItemGroupHeader={props => (+ <CategoryItemGroupHeader+ {...props}+ style={{+ ...styles.largeText,+ color: theme.menuItemTextHeader,+ paddingTop: 10,+ paddingBottom: 10,+ }}+ />+ )}+ renderCategoryItem={props => (+ <CategoryItem+ {...props}+ style={{+ ...itemStyle,+ color: theme.menuItemText,+ borderRadius: 0,+ borderTop: `1px solid ${theme.pillBorder}`,+ }}+ />+ )}{...autocompleteProps}/>);diff --git a/packages/desktop-client/src/components/transactions/MobileTransaction.js b/packages/desktop-client/src/components/transactions/MobileTransaction.jsindex 3258b88fd6..499f02e677 100644--- a/packages/desktop-client/src/components/transactions/MobileTransaction.js+++ b/packages/desktop-client/src/components/transactions/MobileTransaction.js@@ -674,6 +674,7 @@ class TransactionEditInner extends PureComponent {<ButtononClick={() => this.onDelete()}style={{+ height: 40,borderWidth: 0,paddingVertical: 5,marginLeft: styles.mobileEditingPadding,@@ -707,8 +708,8 @@ class TransactionEditInner extends PureComponent {style={{paddingLeft: styles.mobileEditingPadding,paddingRight: styles.mobileEditingPadding,- paddingTop: 15,- paddingBottom: 15,+ paddingTop: 10,+ paddingBottom: 10,backgroundColor: theme.tableHeaderBackground,borderTopWidth: 1,borderColor: theme.tableBorder,@@ -717,7 +718,7 @@ class TransactionEditInner extends PureComponent {}}>{adding ? (- <Button onClick={() => this.onAdd()}>+ <Button style={{ height: 40 }} onClick={() => this.onAdd()}><SvgAddwidth={17}height={17}@@ -734,7 +735,7 @@ class TransactionEditInner extends PureComponent {</Text></Button>) : (- <Button onClick={() => this.onSave()}>+ <Button style={{ height: 40 }} onClick={() => this.onSave()}><SvgPencilWriteAlternatestyle={{ width: 16, height: 16, color: theme.formInputText }}/>diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.test.js b/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsindex 63ec402a49..edc14f7f19 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.test.js+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.test.js@@ -430,12 +430,13 @@ describe('Transactions', () => {test('dropdown automatically opens and can be filtered', async () => {const { container } = renderTransactions();+ let categories = categoryGroups.flatMap(group => group.categories);let input = await editField(container, 'category', 2);let tooltip = container.querySelector('[data-testid="autocomplete"]');expect(tooltip).toBeTruthy();expect([...tooltip.querySelectorAll('[data-testid*="category-item"]')].length,- ).toBe(9);+ ).toBe(categoryGroups.length + categories.length);await userEvent.clear(input);await userEvent.type(input, 'Gener');@@ -446,13 +447,13 @@ describe('Transactions', () => {expect(items.length).toBe(2);expect(items[0].textContent).toBe('Usual Expenses');expect(items[1].textContent).toBe('General');- expect(items[1].dataset['testid']).toBe('category-item-highlighted');+ expect(items[1].dataset['highlighted']).toBeDefined();// It should not allow filtering on group namesawait userEvent.clear(input);await userEvent.type(input, 'Usual Expenses');- items = tooltip.querySelectorAll('[data-testid*="category-item"]');+ items = tooltip.querySelectorAll('[data-testid$="category-item"]');expect(items.length).toBe(0);});@@ -463,18 +464,14 @@ describe('Transactions', () => {let tooltip = container.querySelector('[data-testid="autocomplete"]');// No item should be highlighted- let highlighted = tooltip.querySelector(- '[data-testid="category-item-highlighted"]',- );- expect(highlighted).toBe(null);+ let highlighted = tooltip.querySelector('[data-highlighted]');+ expect(highlighted).toBeNull();await userEvent.keyboard('[ArrowDown][ArrowDown][ArrowDown][ArrowDown]');// The right item should be highlighted- highlighted = tooltip.querySelector(- '[data-testid="category-item-highlighted"]',- );- expect(highlighted).toBeTruthy();+ highlighted = tooltip.querySelector('[data-highlighted]');+ expect(highlighted).not.toBeNull();expect(highlighted.textContent).toBe('General');expect(getTransactions()[2].category).toBe(@@ -507,20 +504,16 @@ describe('Transactions', () => {let tooltip = container.querySelector('[data-testid="autocomplete"]');// Make sure none of the items are highlighted- let items = tooltip.querySelectorAll('[data-testid="category-item"]');- let highlighted = tooltip.querySelector(- '[data-testid="category-item-highlighted"]',- );- expect(highlighted).toBe(null);+ let items = tooltip.querySelectorAll('[data-testid$="category-item"]');+ let highlighted = tooltip.querySelector('[data-highlighted]');+ expect(highlighted).toBeNull();// Hover over an itemawait userEvent.hover(items[2]);// Make sure the expected category is highlighted- highlighted = tooltip.querySelector(- '[data-testid="category-item-highlighted"]',- );- expect(highlighted).toBeTruthy();+ highlighted = tooltip.querySelector('[data-highlighted]');+ expect(highlighted).not.toBeNull();expect(highlighted.textContent).toBe('General');// Click the item and check the before/after values@@ -546,17 +539,15 @@ describe('Transactions', () => {let oldCategory = getTransactions()[2].category;let tooltip = container.querySelector('[data-testid="autocomplete"]');- let items = tooltip.querySelectorAll('[data-testid="category-item"]');+ let items = tooltip.querySelectorAll('[data-testid$="category-item"]');// Hover over a few of the items to highlight themawait userEvent.hover(items[2]);await userEvent.hover(items[3]);// Make sure one of them is highlighted- let highlighted = tooltip.querySelector(- '[data-testid="category-item-highlighted"]',- );- expect(highlighted).toBeTruthy();+ let highlighted = tooltip.querySelectorAll('[data-highlighted]');+ expect(highlighted).toHaveLength(1);// Navigate away from the field with the keyboardawait userEvent.type(input, '[Tab]');diff --git a/upcoming-release-notes/1900.md b/upcoming-release-notes/1900.mdnew file mode 100644index 0000000000..7dea1f9e08--- /dev/null+++ b/upcoming-release-notes/1900.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [joel-jeremy]+---++Larger mobile autocomplete component fonts and paddings.