22// SearchStaticList (src/components/Search/SearchStaticList.tsx) used for fast
33// perceived performance. If you change the narrow-layout UI here, verify the
44// static version still looks visually identical.
5- import React from 'react' ;
5+ import React , { useEffect , useState } from 'react' ;
66import type { OnyxEntry } from 'react-native-onyx' ;
77// Use the original useOnyx hook to get the real-time data from Onyx and not from the snapshot
88// eslint-disable-next-line no-restricted-imports
@@ -11,9 +11,11 @@ import {useDelegateNoAccessActions, useDelegateNoAccessState} from '@components/
1111import { useSearchStateContext } from '@components/Search/SearchContext' ;
1212import type { TransactionListItemProps , TransactionListItemType } from '@components/Search/SearchList/ListItem/types' ;
1313import type { ListItem } from '@components/SelectionList/types' ;
14+ import { useEditingCellState } from '@components/Table/EditableCell' ;
1415import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails' ;
1516import useOnyx from '@hooks/useOnyx' ;
1617import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
18+ import useTransactionInlineEdit from '@hooks/useTransactionInlineEdit' ;
1719import type { TransactionPreviewData } from '@libs/actions/Search' ;
1820import { handleActionButtonPress as handleActionButtonPressUtil } from '@libs/actions/Search' ;
1921import { syncMissingAttendeesViolation } from '@libs/AttendeeUtils' ;
@@ -127,6 +129,66 @@ function TransactionListItem<TItem extends ListItem>({
127129
128130 const { isDelegateAccessRestricted} = useDelegateNoAccessState ( ) ;
129131 const { showDelegateNoAccessModal} = useDelegateNoAccessActions ( ) ;
132+ const { isEditingCell, wasRecentlyEditingCell} = useEditingCellState ( ) ;
133+ const [ shouldDisableHoverStyle , setShouldDisableHoverStyle ] = useState ( false ) ;
134+
135+ // When a popover is opened during inline editing, onHoverOut never fires after editing ends, leaving the hover style stuck.
136+ // Disable it until the next intentional hover (onHoverIn).
137+ // See: https://github.com/Expensify/App/pull/83127#issuecomment-4114490080
138+ useEffect ( ( ) => {
139+ if ( ! wasRecentlyEditingCell ) {
140+ return ;
141+ }
142+ queueMicrotask ( ( ) => setShouldDisableHoverStyle ( true ) ) ;
143+ } , [ wasRecentlyEditingCell ] ) ;
144+
145+ const {
146+ canEditDate,
147+ canEditMerchant,
148+ canEditDescription,
149+ canEditCategory,
150+ canEditAmount,
151+ canEditTag,
152+ onEditDate,
153+ onEditMerchant,
154+ onEditDescription,
155+ onEditCategory,
156+ onEditAmount,
157+ onEditTag,
158+ wasEditingOnMouseDownRef,
159+ } = useTransactionInlineEdit ( {
160+ transactionID : transactionItem . transactionID ,
161+ hash : currentSearchHash ,
162+ linkedReportAction : transactionItem . reportAction ,
163+ } ) ;
164+
165+ const handleOnPress = ( ) => {
166+ // Consume the tap that dismissed an editing cell — a second tap will open the row.
167+ // We check the ref rather than isEditingCell because blur fires before onPress and resets the state.
168+ if ( wasEditingOnMouseDownRef . current ) {
169+ wasEditingOnMouseDownRef . current = false ;
170+ return ;
171+ }
172+ // react-native-web fires onPress on Space for role="button" elements; suppress it while a cell is being edited.
173+ if ( isEditingCell ) {
174+ return ;
175+ }
176+ if ( isDeletedTransaction && ! canSelectMultiple ) {
177+ return ;
178+ }
179+ onSelectRow ( item , transactionPreviewData ) ;
180+ } ;
181+
182+ const handleOnMouseDown = ( e ?: React . MouseEvent ) => {
183+ wasEditingOnMouseDownRef . current = isEditingCell ;
184+
185+ // Skip preventDefault when editing so the browser naturally blurs the input (triggering save/cancel).
186+ if ( ! isEditingCell ) {
187+ e ?. preventDefault ( ) ;
188+ }
189+ } ;
190+
191+ const handleOnHoverIn = ( ) => setShouldDisableHoverStyle ( false ) ;
130192
131193 const handleActionButtonPress = ( ) => {
132194 handleActionButtonPressUtil ( {
@@ -170,6 +232,22 @@ function TransactionListItem<TItem extends ListItem>({
170232 exportedReportActions,
171233 nonPersonalAndWorkspaceCards,
172234 isAttendeesEnabledForMovingPolicy,
235+ shouldDisableHoverStyle,
236+ onPressRow : handleOnPress ,
237+ onMouseDownRow : handleOnMouseDown ,
238+ onHoverInRow : handleOnHoverIn ,
239+ onEditDate,
240+ onEditMerchant,
241+ onEditDescription,
242+ onEditCategory,
243+ onEditAmount,
244+ onEditTag,
245+ canEditDate,
246+ canEditMerchant,
247+ canEditDescription,
248+ canEditCategory,
249+ canEditAmount,
250+ canEditTag,
173251 } ;
174252
175253 if ( ! isLargeScreenWidth ) {
0 commit comments