Skip to content

Commit 2f1e0f6

Browse files
authored
Merge pull request Expensify#89364 from Expensify/claude-nestedRowHoverAndClick
Fix nested row hover and click in grouped search results
2 parents cc018c3 + e488f32 commit 2f1e0f6

2 files changed

Lines changed: 56 additions & 49 deletions

File tree

src/components/Search/SearchList/ListItem/TransactionGroupListExpanded.tsx

Lines changed: 55 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {getReportAction} from '@libs/ReportActionsUtils';
2626
import {getReportOrDraftReport} from '@libs/ReportUtils';
2727
import {createAndOpenSearchTransactionThread, getColumnsToShow, getTableMinWidth} from '@libs/SearchUIUtils';
2828
import type {SkeletonSpanReasonAttributes} from '@libs/telemetry/useSkeletonSpan';
29-
import {getTransactionViolations, isDeletedTransaction} from '@libs/TransactionUtils';
29+
import {getTransactionViolations, isDeletedTransaction, isTransactionPendingDelete} from '@libs/TransactionUtils';
3030
import type {TransactionPreviewData} from '@userActions/Search';
3131
import {setActiveTransactionIDs} from '@userActions/TransactionThreadNavigation';
3232
import CONST from '@src/CONST';
@@ -265,59 +265,66 @@ function TransactionGroupListExpanded<TItem extends ListItem>({
265265
{visibleTransactions.map((transaction, index) => {
266266
const shouldShowBottomBorder = !isLastTransaction(index);
267267
const exportedReportActions = Object.values(transactionsSnapshot?.data?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${transaction?.reportID}`] ?? {});
268+
const isDeletedOrPendingDelete = isDeletedTransaction(transaction) || isTransactionPendingDelete(transaction);
268269

269-
const transactionRow = (
270-
<TransactionItemRow
271-
report={transaction.report}
272-
policy={transaction.policy}
273-
transactionItem={transaction}
274-
violations={getTransactionViolations(transaction, violations, currentUserDetails.email ?? '', currentUserDetails.accountID, transaction.report, transaction.policy)}
275-
isSelected={!!transaction.isSelected}
276-
dateColumnSize={dateColumnSize}
277-
amountColumnSize={amountColumnSize}
278-
taxAmountColumnSize={taxAmountColumnSize}
279-
shouldShowTooltip={showTooltip}
280-
shouldUseNarrowLayout={!isLargeScreenWidth}
281-
shouldShowCheckbox={!!canSelectMultiple}
282-
checkboxSentryLabel={CONST.SENTRY_LABEL.SEARCH.EXPANDED_TRANSACTION_ROW_CHECKBOX}
283-
onCheckboxPress={() => onSelectionButtonPress?.(transaction as unknown as TItem)}
284-
columns={currentColumns}
285-
onButtonPress={() => handleButtonPress(transaction)}
286-
style={[styles.noBorderRadius, isLargeScreenWidth ? [styles.p3, styles.pv2, styles.searchTableRowHeight] : styles.p4, styles.flex1]}
287-
isReportItemChild
288-
isInSingleTransactionReport={isInSingleTransactionReport}
289-
shouldShowBottomBorder={shouldShowBottomBorder}
290-
onArrowRightPress={isDeletedTransaction(transaction) ? undefined : () => openReportInRHP(transaction)}
291-
shouldShowArrowRightOnNarrowLayout
292-
reportActions={exportedReportActions}
293-
policyForMovingExpenses={policyForMovingExpenses}
294-
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
295-
isActionColumnWide={isActionColumnWide}
296-
/>
297-
);
298270
return (
299271
<OfflineWithFeedback
300272
pendingAction={transaction.pendingAction}
301273
key={transaction.transactionID}
302274
>
303-
{!isLargeScreenWidth ? (
304-
<PressableWithFeedback
305-
onPress={() => handleOnPress(transaction)}
306-
onLongPress={() => onLongPress?.(transaction)}
307-
accessibilityRole={CONST.ROLE.BUTTON}
308-
accessibilityLabel={transaction.text ?? ''}
309-
isNested
310-
onMouseDown={(e) => e.preventDefault()}
311-
hoverStyle={[!transaction.isDisabled && styles.hoveredComponentBG]}
312-
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true, [CONST.INNER_BOX_SHADOW_ELEMENT]: false}}
313-
id={transaction.transactionID}
314-
sentryLabel={CONST.SENTRY_LABEL.SEARCH.EXPANDED_TRANSACTION_ROW}
315-
>
316-
{transactionRow}
317-
</PressableWithFeedback>
318-
) : (
319-
transactionRow
320-
)}
275+
<PressableWithFeedback
276+
onPress={isDeletedOrPendingDelete && !canSelectMultiple ? undefined : () => handleOnPress(transaction)}
277+
disabled={isDeletedOrPendingDelete && !transaction.isSelected}
278+
onLongPress={() => onLongPress?.(transaction)}
279+
accessibilityRole={CONST.ROLE.BUTTON}
280+
accessibilityLabel={transaction.text ?? ''}
281+
isNested
282+
onMouseDown={(e) => e.preventDefault()}
283+
hoverStyle={[!transaction.isDisabled && styles.hoveredComponentBG, transaction.isSelected && styles.activeComponentBG]}
284+
wrapperStyle={isDeletedOrPendingDelete ? styles.cursorDisabled : undefined}
285+
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true, [CONST.INNER_BOX_SHADOW_ELEMENT]: false}}
286+
id={transaction.transactionID}
287+
sentryLabel={CONST.SENTRY_LABEL.SEARCH.EXPANDED_TRANSACTION_ROW}
288+
>
289+
{({hovered}) => (
290+
<TransactionItemRow
291+
report={transaction.report}
292+
policy={transaction.policy}
293+
transactionItem={transaction}
294+
violations={getTransactionViolations(
295+
transaction,
296+
violations,
297+
currentUserDetails.email ?? '',
298+
currentUserDetails.accountID,
299+
transaction.report,
300+
transaction.policy,
301+
)}
302+
isSelected={!!transaction.isSelected}
303+
isDisabled={isTransactionPendingDelete(transaction)}
304+
dateColumnSize={dateColumnSize}
305+
amountColumnSize={amountColumnSize}
306+
taxAmountColumnSize={taxAmountColumnSize}
307+
shouldShowTooltip={showTooltip}
308+
shouldUseNarrowLayout={!isLargeScreenWidth}
309+
shouldShowCheckbox={!!canSelectMultiple}
310+
checkboxSentryLabel={CONST.SENTRY_LABEL.SEARCH.EXPANDED_TRANSACTION_ROW_CHECKBOX}
311+
onCheckboxPress={() => onSelectionButtonPress?.(transaction as unknown as TItem)}
312+
columns={currentColumns}
313+
onButtonPress={() => handleButtonPress(transaction)}
314+
style={[styles.noBorderRadius, isLargeScreenWidth ? [styles.p3, styles.pv2, styles.searchTableRowHeight] : styles.p4, styles.flex1]}
315+
isReportItemChild
316+
isInSingleTransactionReport={isInSingleTransactionReport}
317+
shouldShowBottomBorder={shouldShowBottomBorder}
318+
onArrowRightPress={isDeletedOrPendingDelete ? undefined : () => openReportInRHP(transaction)}
319+
shouldShowArrowRightOnNarrowLayout
320+
reportActions={exportedReportActions}
321+
policyForMovingExpenses={policyForMovingExpenses}
322+
nonPersonalAndWorkspaceCards={nonPersonalAndWorkspaceCards}
323+
isActionColumnWide={isActionColumnWide}
324+
isHover={hovered}
325+
/>
326+
)}
327+
</PressableWithFeedback>
321328
</OfflineWithFeedback>
322329
);
323330
})}

src/components/Search/SearchList/ListItem/TransactionGroupListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ function TransactionGroupListItem<TItem extends ListItem>({
527527
accessibilityLabel={item.text ?? ''}
528528
role={getButtonRole(true)}
529529
isNested
530-
hoverStyle={[!item.isDisabled && styles.hoveredComponentBG, isItemSelected && styles.activeComponentBG]}
530+
hoverStyle={[!isExpanded && !item.isDisabled && styles.hoveredComponentBG, isItemSelected && styles.activeComponentBG]}
531531
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true, [CONST.INNER_BOX_SHADOW_ELEMENT]: false}}
532532
onMouseDown={(e) => e.preventDefault()}
533533
id={item.keyForList ?? ''}

0 commit comments

Comments
 (0)