A local-first personal finance app
♻️ (tooltip) refactoring to react-aria (vol.10) (#2828)
Matiss Janis Aboltinsf81c452ba5b2
diff --git a/packages/desktop-client/src/components/modals/CreateAccountModal.tsx b/packages/desktop-client/src/components/modals/CreateAccountModal.tsxindex 4f042cd1d5..d865231284 100644--- a/packages/desktop-client/src/components/modals/CreateAccountModal.tsx+++ b/packages/desktop-client/src/components/modals/CreateAccountModal.tsx@@ -1,5 +1,5 @@// @ts-strict-ignore-import React, { useEffect, useState } from 'react';+import React, { useEffect, useRef, useState } from 'react';import { send } from 'loot-core/src/platform/client/fetch';@@ -16,10 +16,10 @@ import { Link } from '../common/Link';import { Menu } from '../common/Menu';import { Modal } from '../common/Modal';import { Paragraph } from '../common/Paragraph';+import { Popover } from '../common/Popover';import { Text } from '../common/Text';import { View } from '../common/View';import { type CommonModalProps } from '../Modals';-import { Tooltip } from '../tooltips';type CreateAccountProps = {modalProps: CommonModalProps;@@ -38,6 +38,7 @@ export function CreateAccountModal({const [isSimpleFinSetupComplete, setIsSimpleFinSetupComplete] =useState(null);const [menuGoCardlessOpen, setGoCardlessMenuOpen] = useState<boolean>(false);+ const triggerRef = useRef(null);const [menuSimplefinOpen, setSimplefinMenuOpen] = useState<boolean>(false);const onConnectGoCardless = () => {@@ -235,39 +236,40 @@ export function CreateAccountModal({: 'Set up GoCardless for bank sync'}</ButtonWithLoading>{isGoCardlessSetupComplete && (- <Button- type="bare"- onClick={() => setGoCardlessMenuOpen(true)}- aria-label="Menu"- >- <SvgDotsHorizontalTriple- width={15}- height={15}- style={{ transform: 'rotateZ(90deg)' }}- />- {menuGoCardlessOpen && (- <Tooltip- position="bottom-right"- width={200}- style={{ padding: 0 }}- onClose={() => setGoCardlessMenuOpen(false)}- >- <Menu- onMenuSelect={item => {- if (item === 'reconfigure') {- onGoCardlessReset();- }- }}- items={[- {- name: 'reconfigure',- text: 'Reset GoCardless credentials',- },- ]}- />- </Tooltip>- )}- </Button>+ <>+ <Button+ ref={triggerRef}+ type="bare"+ onClick={() => setGoCardlessMenuOpen(true)}+ aria-label="Menu"+ >+ <SvgDotsHorizontalTriple+ width={15}+ height={15}+ style={{ transform: 'rotateZ(90deg)' }}+ />+ </Button>++ <Popover+ triggerRef={triggerRef}+ isOpen={menuGoCardlessOpen}+ onOpenChange={() => setGoCardlessMenuOpen(false)}+ >+ <Menu+ onMenuSelect={item => {+ if (item === 'reconfigure') {+ onGoCardlessReset();+ }+ }}+ items={[+ {+ name: 'reconfigure',+ text: 'Reset GoCardless credentials',+ },+ ]}+ />+ </Popover>+ </>)}</View><Text style={{ lineHeight: '1.4em', fontSize: 15 }}>@@ -303,39 +305,39 @@ export function CreateAccountModal({: 'Set up SimpleFIN for bank sync'}</ButtonWithLoading>{isSimpleFinSetupComplete && (- <Button- type="bare"- onClick={() => setSimplefinMenuOpen(true)}- aria-label="Menu"- >- <SvgDotsHorizontalTriple- width={15}- height={15}- style={{ transform: 'rotateZ(90deg)' }}- />- {menuSimplefinOpen && (- <Tooltip- position="bottom-right"- width={200}- style={{ padding: 0 }}- onClose={() => setSimplefinMenuOpen(false)}- >- <Menu- onMenuSelect={item => {- if (item === 'reconfigure') {- onSimpleFinReset();- }- }}- items={[- {- name: 'reconfigure',- text: 'Reset SimpleFIN credentials',- },- ]}- />- </Tooltip>- )}- </Button>+ <>+ <Button+ ref={triggerRef}+ type="bare"+ onClick={() => setSimplefinMenuOpen(true)}+ aria-label="Menu"+ >+ <SvgDotsHorizontalTriple+ width={15}+ height={15}+ style={{ transform: 'rotateZ(90deg)' }}+ />+ </Button>+ <Popover+ triggerRef={triggerRef}+ isOpen={menuSimplefinOpen}+ onOpenChange={() => setSimplefinMenuOpen(false)}+ >+ <Menu+ onMenuSelect={item => {+ if (item === 'reconfigure') {+ onSimpleFinReset();+ }+ }}+ items={[+ {+ name: 'reconfigure',+ text: 'Reset SimpleFIN credentials',+ },+ ]}+ />+ </Popover>+ </>)}</View><Text style={{ lineHeight: '1.4em', fontSize: 15 }}>diff --git a/packages/desktop-client/src/components/schedules/SchedulesTable.tsx b/packages/desktop-client/src/components/schedules/SchedulesTable.tsxindex aa6a560af8..dae97da2dd 100644--- a/packages/desktop-client/src/components/schedules/SchedulesTable.tsx+++ b/packages/desktop-client/src/components/schedules/SchedulesTable.tsx@@ -363,7 +363,6 @@ export function SchedulesTable({items={items as ScheduleEntity[]}renderItem={renderItem}renderEmpty={filter ? 'No matching schedules' : 'No schedules'}- allowPopupsEscape={items.length < 6}/></View>);diff --git a/packages/desktop-client/src/components/table.tsx b/packages/desktop-client/src/components/table.tsxindex b354c6b353..7a7002410b 100644--- a/packages/desktop-client/src/components/table.tsx+++ b/packages/desktop-client/src/components/table.tsx@@ -14,6 +14,7 @@ import React, {type UIEvent,type ReactElement,type Ref,+ type MutableRefObject,} from 'react';import { useStore } from 'react-redux';import AutoSizer from 'react-virtualized-auto-sizer';@@ -42,7 +43,6 @@ import {import { type Binding } from './spreadsheet';import { type FormatType, useFormat } from './spreadsheet/useFormat';import { useSheetValue } from './spreadsheet/useSheetValue';-import { IntersectionBoundary } from './tooltips';export const ROW_HEIGHT = 32;@@ -276,16 +276,13 @@ type RowProps = ComponentProps<typeof View> & {inset?: number;collapsed?: boolean;};-export function Row({- inset = 0,- collapsed,- children,- height,- style,- ...nativeProps-}: RowProps) {+export const Row = forwardRef<HTMLDivElement, RowProps>(function Row(+ { inset = 0, collapsed, children, height, style, ...nativeProps },+ ref,+) {return (<View+ ref={ref}style={{flexDirection: 'row',height: height || ROW_HEIGHT,@@ -302,7 +299,7 @@ export function Row({{inset !== 0 && <Field width={inset} />}</View>);-}+});const inputCellStyle = {padding: '5px 3px',@@ -900,9 +897,8 @@ type TableProps<T extends TableItem = TableItem> = {loadMore?: () => void;style?: CSSProperties;navigator?: ReturnType<typeof useTableNavigator<T>>;- listRef?: unknown;+ listContainerRef?: MutableRefObject<HTMLDivElement>;onScroll?: () => void;- allowPopupsEscape?: boolean;isSelected?: (id: TableItem['id']) => boolean;saveScrollWidth?: (parent, child) => void;};@@ -924,9 +920,9 @@ export const Table = forwardRef(style,navigator,onScroll,- allowPopupsEscape,isSelected,saveScrollWidth,+ listContainerRef,...props},ref,@@ -942,7 +938,8 @@ export const Table = forwardRef(const { onEdit, editingId, focusedField, getNavigatorProps } = navigator;const list = useRef(null);- const listContainer = useRef(null);+ const listContainerInnerRef = useRef<HTMLDivElement>(null);+ const listContainer = listContainerRef || listContainerInnerRef;const scrollContainer = useRef(null);const initialScrollTo = useRef(null);const listInitialized = useRef(false);@@ -1144,37 +1141,33 @@ export const Table = forwardRef(}return (- <IntersectionBoundary.Provider- value={!allowPopupsEscape && listContainer}- >- <AvoidRefocusScrollProvider>- <FixedSizeList- ref={list}- header={contentHeader}- innerRef={listContainer}- outerRef={scrollContainer}- width={width}- height={height}- renderRow={renderRow}- itemCount={count || items.length}- itemSize={rowHeight - 1}- itemKey={- getItemKey || ((index: number) => items[index].id)- }- indexForKey={key =>- items.findIndex(item => item.id === key)- }- initialScrollOffset={- initialScrollTo.current- ? getScrollOffset(height, initialScrollTo.current)- : 0- }- overscanCount={5}- onItemsRendered={onItemsRendered}- onScroll={onScroll}- />- </AvoidRefocusScrollProvider>- </IntersectionBoundary.Provider>+ <AvoidRefocusScrollProvider>+ <FixedSizeList+ ref={list}+ header={contentHeader}+ innerRef={listContainer}+ outerRef={scrollContainer}+ width={width}+ height={height}+ renderRow={renderRow}+ itemCount={count || items.length}+ itemSize={rowHeight - 1}+ itemKey={+ getItemKey || ((index: number) => items[index].id)+ }+ indexForKey={key =>+ items.findIndex(item => item.id === key)+ }+ initialScrollOffset={+ initialScrollTo.current+ ? getScrollOffset(height, initialScrollTo.current)+ : 0+ }+ overscanCount={5}+ onItemsRendered={onItemsRendered}+ onScroll={onScroll}+ />+ </AvoidRefocusScrollProvider>);}}</AutoSizer>diff --git a/packages/desktop-client/src/components/tooltips.tsx b/packages/desktop-client/src/components/tooltips.tsxdeleted file mode 100644index b6182a5d02..0000000000--- a/packages/desktop-client/src/components/tooltips.tsx+++ /dev/null@@ -1,394 +0,0 @@-// @ts-strict-ignore-import {- Component,- createContext,- createRef,- type RefObject,- type ReactNode,- type ContextType,-} from 'react';-import ReactDOM from 'react-dom';--import { css } from 'glamor';--import { type CSSProperties, styles, theme } from '../style';--export const IntersectionBoundary = createContext<RefObject<HTMLElement>>(null);--type TooltipPosition =- | 'top'- | 'top-left'- | 'top-right'- | 'bottom'- | 'bottom-left'- | 'bottom-right'- | 'bottom-stretch'- | 'top-stretch'- | 'bottom-center'- | 'top-center'- | 'left-center'- | 'right';--type TooltipProps = {- position?: TooltipPosition;- onClose?: () => void;- forceLayout?: boolean;- forceTop?: number;- ignoreBoundary?: boolean;- targetRect?: DOMRect;- offset?: number;- style?: CSSProperties;- width?: number;- children: ReactNode;- targetHeight?: number;-};-type MutableDomRect = {- top: number;- left: number;- width: number;- height: number;-};--// @deprecated: please use `Tooltip` component in `common` folder-export class Tooltip extends Component<TooltipProps> {- static contextType = IntersectionBoundary;- position: TooltipPosition;- contentRef: RefObject<HTMLDivElement>;- cleanup: () => void;- target: HTMLDivElement;- context: ContextType<typeof IntersectionBoundary> = this.context; // assign type to context without using declare.-- constructor(props) {- super(props);- this.position = props.position || 'bottom-right';- this.contentRef = createRef<HTMLDivElement>();- }-- isHTMLElement(element: unknown): element is HTMLElement {- return element instanceof HTMLElement;- }-- setup() {- this.layout();-- const pointerDownHandler = e => {- let node = e.target;-- while (node && node !== document.documentElement) {- // Allow clicking reach popover that mount outside of- // tooltips. Might need to think about this more, like what- // kind of things can be click that shouldn't close a tooltip?- if (node.dataset.istooltip || node.dataset.reachPopover != null) {- break;- }-- node = node.parentNode;- }-- if (node === document.documentElement) {- this.props.onClose?.();- }- };-- const escHandler = e => {- if (e.key === 'Escape') {- this.props.onClose?.();- }- };-- window.document.addEventListener('pointerdown', pointerDownHandler, false);- this.contentRef.current?.addEventListener('keydown', escHandler, false);-- this.cleanup = () => {- window.document.removeEventListener(- 'pointerdown',- pointerDownHandler,- false,- );- this.contentRef.current?.removeEventListener(- 'keydown',- escHandler,- false,- );- };- }-- componentDidMount() {- if (this.getContainer()) {- this.setup();- } else {- // TODO: write comment :)- this.forceUpdate(() => {- if (this.getContainer()) {- this.setup();- } else {- console.log('Warning: could not mount tooltip, container missing');- }- });- }- }-- componentDidUpdate(prevProps) {- // If providing the target rect manually, we can dynamically- // update to it. We can't do this if we are reading directly from- // the DOM since we don't know when it's updated.- if (- prevProps.targetRect !== this.props.targetRect ||- prevProps.forceTop !== this.props.forceTop ||- this.props.forceLayout- ) {- this.layout();- }- }-- getContainer(): HTMLElement {- const { ignoreBoundary = false } = this.props;-- if (!ignoreBoundary && this.context) {- return this.context.current;- }- return document.body;- }-- getBoundsContainer() {- // If the container is a scrollable element, we want to do all the- // bounds checking on the parent DOM element instead- const container = this.getContainer();-- if (- container.parentNode &&- this.isHTMLElement(container.parentNode) &&- container.parentNode.style.overflow === 'auto'- ) {- return container.parentNode;- }- return container;- }-- layout() {- const { targetRect, offset = 0 } = this.props;- const contentEl = this.contentRef.current;- if (!contentEl) {- return;- }-- const box = contentEl.getBoundingClientRect();-- const anchorEl = this.target.parentNode;-- let anchorRect: MutableDomRect | undefined =- targetRect ||- (this.isHTMLElement(anchorEl)- ? anchorEl?.getBoundingClientRect()- : undefined);-- if (!anchorRect) {- return;- }-- // Copy it so we can mutate it- anchorRect = {- top: anchorRect.top,- left: anchorRect.left,- width: anchorRect.width,- height: anchorRect.height,- };-- const container = this.getBoundsContainer();- if (!container) {- return;- }-- const containerRect = container.getBoundingClientRect();- anchorRect.left -= containerRect.left;- anchorRect.top -= containerRect.top;-- // This is a hack, but allow consumers to force a top position if- // they already know it. This allows them to provide consistent- // updates. We should generalize this and `targetRect`- if (this.props.forceTop) {- anchorRect.top = this.props.forceTop;- } else {- const boxHeight = box.height + offset;- const testTop = anchorRect.top - boxHeight;- const testBottom = anchorRect.top + anchorRect.height + boxHeight;-- if (- // If it doesn't fit above it, switch it to below- (this.position.indexOf('top') !== -1 && testTop < containerRect.top) ||- // If it doesn't fit below it, switch it above only if it does- // fit above it- (this.position.indexOf('bottom') !== -1 &&- testBottom > containerRect.height &&- testTop > 0)- ) {- // Invert the position- this.position = this.getOppositePosition(this.position);- }-- anchorRect.top += container.scrollTop;- }-- const style = this.getStyleForPosition(- this.position,- box,- anchorRect,- this.getContainer().getBoundingClientRect(),- offset,- );-- contentEl.style.top = style.top;- contentEl.style.bottom = style.bottom;- contentEl.style.left = style.left;- contentEl.style.right = style.right;- contentEl.style.width = style.width;- }-- componentWillUnmount() {- if (this.cleanup) {- this.cleanup();- }- }-- getOppositePosition(position) {- switch (position) {- case 'top':- case 'top-left':- return 'bottom';- case 'top-right':- return 'bottom-right';- case 'bottom':- case 'bottom-left':- return 'top';- case 'bottom-right':- return 'top-right';- case 'bottom-stretch':- return 'top-stretch';- case 'top-stretch':- return 'bottom-stretch';- case 'bottom-center':- return 'top-center';- case 'top-center':- return 'bottom-center';- case 'right':- return 'right';- default:- }- }-- getStyleForPosition(position, boxRect, anchorRect, containerRect, offset) {- const style = {- top: 'inherit',- bottom: 'inherit',- left: 'inherit',- right: 'inherit',- width: undefined as string | undefined,- };-- if (- position === 'top' ||- position === 'top-right' ||- position === 'top-left'- ) {- style.top = anchorRect.top - boxRect.height - offset + 'px';- if (position === 'top-right') {- style.left =- anchorRect.left + (anchorRect.width - boxRect.width) + 'px';- } else {- style.left = anchorRect.left + 'px';- // style.right = 0;- }- } else if (- position === 'bottom' ||- position === 'bottom-right' ||- position === 'bottom-left'- ) {- style.top = anchorRect.top + anchorRect.height + offset + 'px';- if (position === 'bottom-right') {- style.left =- anchorRect.left + (anchorRect.width - boxRect.width) + 'px';- } else {- style.left = anchorRect.left + 'px';- // style.right = 0;- }- } else if (position === 'bottom-center') {- style.top = anchorRect.top + anchorRect.height + offset + 'px';- style.left =- anchorRect.left - (boxRect.width - anchorRect.width) / 2 + 'px';- } else if (position === 'top-center') {- style.top = anchorRect.top - boxRect.height - offset + 'px';- style.left =- anchorRect.left - (boxRect.width - anchorRect.width) / 2 + 'px';- } else if (position === 'left-center') {- style.top =- anchorRect.top - (boxRect.height - anchorRect.height) / 2 + 'px';- style.left = anchorRect.left - boxRect.width + 'px';- } else if (position === 'top-stretch') {- style.bottom = containerRect.height - anchorRect.top + offset + 'px';- style.left = anchorRect.left + 'px';- style.width = anchorRect.width + 'px';- } else if (position === 'bottom-stretch') {- style.top = anchorRect.top + anchorRect.height + offset + 'px';- style.left = anchorRect.left + 'px';- style.width = anchorRect.width + 'px';- } else if (position === 'right') {- style.top = anchorRect.top + 'px';- style.left = anchorRect.left + anchorRect.width + offset + 'px';- } else {- throw new Error('Invalid position for Tooltip: ' + position);- }- return style;- }-- render() {- const { children, width, style } = this.props;-- const contentStyle = {- position: 'absolute',- zIndex: 3000,-- padding: 5,- width,- ...styles.shadowLarge,- borderRadius: 4,- backgroundColor: theme.menuBackground,- color: theme.menuItemText,- // opacity: 0,- // transition: 'transform .1s, opacity .1s',- // transitionTimingFunction: 'ease-out'- };-- // const enteredStyle = { opacity: 1, transform: 'none' };-- if (!this.getContainer()) {- return null;- }-- return (- <div ref={el => (this.target = el)}>- {ReactDOM.createPortal(- <div- className={`${css(contentStyle, style, styles.darkScrollbar)}`}- ref={this.contentRef}- data-testid={this.props['data-testid'] || 'tooltip'}- data-istooltip- onClick={e => {- // Click events inside a tooltip (e.g. when selecting a menu item) will bubble up- // through the portal to parents in the React tree (as opposed to DOM parents).- // This is undesirable. For example, clicking on a category group on a budget sheet- // toggles that group, and so would clicking on a menu item in the settings menu- // of that category group if the click event wasn't stopped from bubbling up.- // This issue could be handled in different ways, but I think stopping propagation- // here is sane; I can't see a scenario where you would want to take advantage of- // click propagation from a tooltip back to its React parent.- e.stopPropagation();- }}- >- {children}- </div>,- this.getContainer(),- )}- </div>- );- }-}diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.jsx b/packages/desktop-client/src/components/transactions/TransactionsTable.jsxindex f06f4af9e3..ff94c8471b 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.jsx+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.jsx@@ -61,6 +61,7 @@ import { AccountAutocomplete } from '../autocomplete/AccountAutocomplete';import { CategoryAutocomplete } from '../autocomplete/CategoryAutocomplete';import { PayeeAutocomplete } from '../autocomplete/PayeeAutocomplete';import { Button } from '../common/Button';+import { Popover } from '../common/Popover';import { Text } from '../common/Text';import { View } from '../common/View';import { getStatusProps } from '../schedules/StatusBadge';@@ -79,7 +80,6 @@ import {Table,UnexposedCellContent,} from '../table';-import { Tooltip } from '../tooltips';function getDisplayValue(obj, name) {return obj ? obj[name] : '';@@ -681,6 +681,7 @@ function PayeeIcons({}const Transaction = memo(function Transaction({+ allTransactions,transaction: originalTransaction,subtransactions,editing,@@ -711,9 +712,12 @@ const Transaction = memo(function Transaction({onNavigateToTransferAccount,onNavigateToSchedule,onNotesTagClick,+ splitError,+ listContainerRef,}) {const dispatch = useDispatch();const dispatchSelected = useSelectedDispatch();+ const triggerRef = useRef(null);const [prevShowZero, setPrevShowZero] = useState(showZeroInDeposit);const [prevTransaction, setPrevTransaction] = useState(originalTransaction);@@ -881,8 +885,31 @@ const Transaction = memo(function Transaction({? balance: balance + (_inverse ? -1 : 1) * amount;+ // Ok this entire logic is a dirty, dirty hack.. but let me explain.+ // Problem: the split-error Popover (which has the buttons to distribute/add split)+ // renders before schedules are added to the table. After schedules finally load+ // the entire table gets pushed down. But the Popover does not re-calculate+ // its positioning. This is because there is nothing in react-aria that would be+ // watching for the position of the trigger element.+ // Solution: when transactions (this includes schedules) change - we increment+ // a variable (with a small delay in order for the next render cycle to pick up+ // the change instead of the current). We pass the integer to the Popover which+ // causes it to re-calculate the positioning. Thus fixing the problem.+ const [updateId, setUpdateId] = useState(1);+ useEffect(() => {+ // The hack applies to only transactions with split errors+ if (!splitError) {+ return;+ }++ setTimeout(() => {+ setUpdateId(state => state + 1);+ }, 1);+ }, [splitError, allTransactions]);+return (<Row+ ref={triggerRef}style={{backgroundColor: selected? theme.tableRowBackgroundHighlight@@ -909,6 +936,21 @@ const Transaction = memo(function Transaction({...(_unmatched && { opacity: 0.5 }),}}>+ {splitError && listContainerRef.current && (+ <Popover+ arrowSize={updateId}+ triggerRef={triggerRef}+ isOpen+ isNonModal+ style={{ width: 375, padding: 5, maxHeight: '38px !important' }}+ shouldFlip={false}+ placement="bottom end"+ UNSTABLE_portalContainer={listContainerRef.current}+ >+ {splitError}+ </Popover>+ )}+{isChild && (<Field/* Checkmark blank placeholder for Child transaction */@@ -1579,6 +1621,7 @@ function NewTransaction({function TransactionTableInner({tableNavigator,tableRef,+ listContainerRef,dateFormat = 'MM/dd/yyyy',newNavigator,renderEmpty,@@ -1625,7 +1668,7 @@ function TransactionTableInner({}}, [isAddingPrev, props.isAdding, newNavigator]);- const renderRow = ({ item, index, position, editing }) => {+ const renderRow = ({ item, index, editing }) => {const {transactions,selectedItems,@@ -1669,15 +1712,39 @@ function TransactionTableInner({);return (- <>- {hasSplitError && (- <Tooltip- position="bottom-right"- width={350}- forceTop={position}- forceLayout={true}- style={{ transform: 'translate(-5px, 2px)' }}- >+ <Transaction+ allTransactions={props.transactions}+ editing={editing}+ transaction={trans}+ showAccount={showAccount}+ showCategory={showCategory}+ showBalance={showBalances}+ showCleared={showCleared}+ selected={selected}+ highlighted={false}+ added={isNew?.(trans.id)}+ expanded={isExpanded?.(trans.id)}+ matched={isMatched?.(trans.id)}+ showZeroInDeposit={isChildDeposit}+ balance={balances?.[trans.id]?.balance}+ focusedField={editing && tableNavigator.focusedField}+ accounts={accounts}+ categoryGroups={categoryGroups}+ payees={payees}+ dateFormat={dateFormat}+ hideFraction={hideFraction}+ onEdit={tableNavigator.onEdit}+ onSave={props.onSave}+ onDelete={props.onDelete}+ onSplit={props.onSplit}+ onManagePayees={props.onManagePayees}+ onCreatePayee={props.onCreatePayee}+ onToggleSplit={props.onToggleSplit}+ onNavigateToTransferAccount={onNavigateToTransferAccount}+ onNavigateToSchedule={onNavigateToSchedule}+ onNotesTagClick={onNotesTagClick}+ splitError={+ hasSplitError && (<TransactionErrorerror={error}isDeposit={isChildDeposit}@@ -1687,40 +1754,10 @@ function TransactionTableInner({}canDistributeRemainder={emptyChildTransactions.length > 0}/>- </Tooltip>- )}- <Transaction- editing={editing}- transaction={trans}- showAccount={showAccount}- showCategory={showCategory}- showBalance={showBalances}- showCleared={showCleared}- selected={selected}- highlighted={false}- added={isNew?.(trans.id)}- expanded={isExpanded?.(trans.id)}- matched={isMatched?.(trans.id)}- showZeroInDeposit={isChildDeposit}- balance={balances?.[trans.id]?.balance}- focusedField={editing && tableNavigator.focusedField}- accounts={accounts}- categoryGroups={categoryGroups}- payees={payees}- dateFormat={dateFormat}- hideFraction={hideFraction}- onEdit={tableNavigator.onEdit}- onSave={props.onSave}- onDelete={props.onDelete}- onSplit={props.onSplit}- onManagePayees={props.onManagePayees}- onCreatePayee={props.onCreatePayee}- onToggleSplit={props.onToggleSplit}- onNavigateToTransferAccount={onNavigateToTransferAccount}- onNavigateToSchedule={onNavigateToSchedule}- onNotesTagClick={onNotesTagClick}- />- </>+ )+ }+ listContainerRef={listContainerRef}+ />);};@@ -1797,6 +1834,7 @@ function TransactionTableInner({<Tablenavigator={tableNavigator}ref={tableRef}+ listContainerRef={listContainerRef}items={props.transactions}renderItem={renderRow}renderEmpty={renderEmpty}@@ -1833,6 +1871,7 @@ export const TransactionTable = forwardRef((props, ref) => {const prevSplitsExpanded = useRef(null);const tableRef = useRef(null);+ const listContainerRef = useRef(null);const mergedRef = useMergedRefs(tableRef, ref);const transactions = useMemo(() => {@@ -2245,6 +2284,7 @@ export const TransactionTable = forwardRef((props, ref) => {return (<TransactionTableInnertableRef={mergedRef}+ listContainerRef={listContainerRef}{...props}transactions={transactions}transactionMap={transactionMap}diff --git a/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx b/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsxindex c0d133f3a3..e56ec8e06e 100644--- a/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx+++ b/packages/desktop-client/src/components/transactions/TransactionsTable.test.jsx@@ -816,9 +816,7 @@ describe('Transactions', () => {expect(getTransactions()[1].amount).toBe(0);expectErrorToExist(getTransactions().slice(0, 2));- const toolbars = container.querySelectorAll(- '[data-testid="transaction-error"]',- );+ const toolbars = screen.queryAllByTestId('transaction-error');// Make sure the toolbar has appearedexpect(toolbars.length).toBe(1);const toolbar = toolbars[0];@@ -925,9 +923,7 @@ describe('Transactions', () => {expect(getTransactions().length).toBe(5);await userEvent.click(screen.getByTestId('split-transaction-button'));await waitForAutocomplete();- await userEvent.click(- container.querySelector('[data-testid="add-split-button"]'),- );+ await userEvent.click(screen.getByTestId('add-split-button'));expect(getTransactions().length).toBe(7);// The debit field should show the zerosdiff --git a/upcoming-release-notes/2828.md b/upcoming-release-notes/2828.mdnew file mode 100644index 0000000000..fc8bcb87d0--- /dev/null+++ b/upcoming-release-notes/2828.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MatissJanis]+---++Migrating native `Tooltip` component to react-aria Tooltip/Popover (vol.10)