-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: keyboard not dismissed #53907
fix: keyboard not dismissed #53907
Changes from 3 commits
7194ed0
6b2da07
dbd6f62
df34a1f
af03a2b
9e2bcac
d6372b7
2f94bff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import lodashIsEqual from 'lodash/isEqual'; | ||
import React, {memo, useCallback, useContext, useEffect, useMemo, useRef, useState} from 'react'; | ||
import type {GestureResponderEvent, TextInput} from 'react-native'; | ||
import {InteractionManager, View} from 'react-native'; | ||
import {InteractionManager, Keyboard, View} from 'react-native'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import type {ValueOf} from 'type-fest'; | ||
import type {Emoji} from '@assets/emojis/types'; | ||
|
@@ -296,7 +296,7 @@ | |
}: PureReportActionItemProps) { | ||
const {translate} = useLocalize(); | ||
const {shouldUseNarrowLayout} = useResponsiveLayout(); | ||
const reportID = report?.reportID ?? ''; | ||
const reportID = report?.reportID ?? `${CONST.DEFAULT_NUMBER_ID}`; | ||
const theme = useTheme(); | ||
const styles = useThemeStyles(); | ||
const StyleUtils = useStyleUtils(); | ||
|
@@ -507,7 +507,7 @@ | |
const contextValue = useMemo( | ||
() => ({ | ||
anchor: popoverAnchorRef.current, | ||
report: {...report, reportID: report?.reportID ?? ''}, | ||
report: {...report, reportID: report?.reportID ?? `${CONST.DEFAULT_NUMBER_ID}`}, | ||
reportNameValuePairs, | ||
action, | ||
transactionThreadReport, | ||
|
@@ -519,7 +519,7 @@ | |
|
||
const attachmentContextValue = useMemo(() => ({reportID, type: CONST.ATTACHMENT_TYPE.REPORT}), [reportID]); | ||
|
||
const mentionReportContextValue = useMemo(() => ({currentReportID: report?.reportID ?? '-1'}), [report?.reportID]); | ||
const mentionReportContextValue = useMemo(() => ({currentReportID: report?.reportID ?? `${CONST.DEFAULT_NUMBER_ID}`}), [report?.reportID]); | ||
|
||
const actionableItemButtons: ActionableItem[] = useMemo(() => { | ||
if (ReportActionsUtils.isActionableAddPaymentCard(action) && userBillingFundID === undefined && shouldRenderAddPaymentCard()) { | ||
|
@@ -547,23 +547,23 @@ | |
text: 'actionableMentionTrackExpense.submit', | ||
key: `${action.reportActionID}-actionableMentionTrackExpense-submit`, | ||
onPress: () => { | ||
createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? '0', reportID, CONST.IOU.ACTION.SUBMIT, action.reportActionID); | ||
createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? `${CONST.DEFAULT_NUMBER_ID}`, reportID, CONST.IOU.ACTION.SUBMIT, action.reportActionID); | ||
}, | ||
isMediumSized: true, | ||
}, | ||
{ | ||
text: 'actionableMentionTrackExpense.categorize', | ||
key: `${action.reportActionID}-actionableMentionTrackExpense-categorize`, | ||
onPress: () => { | ||
createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? '0', reportID, CONST.IOU.ACTION.CATEGORIZE, action.reportActionID); | ||
createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? `${CONST.DEFAULT_NUMBER_ID}`, reportID, CONST.IOU.ACTION.CATEGORIZE, action.reportActionID); | ||
}, | ||
isMediumSized: true, | ||
}, | ||
{ | ||
text: 'actionableMentionTrackExpense.share', | ||
key: `${action.reportActionID}-actionableMentionTrackExpense-share`, | ||
onPress: () => { | ||
createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? '0', reportID, CONST.IOU.ACTION.SHARE, action.reportActionID); | ||
createDraftTransactionAndNavigateToParticipantSelector(transactionID ?? `${CONST.DEFAULT_NUMBER_ID}`, reportID, CONST.IOU.ACTION.SHARE, action.reportActionID); | ||
}, | ||
isMediumSized: true, | ||
}, | ||
|
@@ -654,11 +654,13 @@ | |
ReportActionsUtils.getOriginalMessage(action)?.type === CONST.IOU.REPORT_ACTION_TYPE.TRACK) | ||
) { | ||
// There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID | ||
const iouReportID = ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ? ReportActionsUtils.getOriginalMessage(action)?.IOUReportID?.toString() ?? '-1' : '-1'; | ||
const iouReportID = ReportActionsUtils.getOriginalMessage(action)?.IOUReportID | ||
? ReportActionsUtils.getOriginalMessage(action)?.IOUReportID?.toString() ?? `${CONST.DEFAULT_NUMBER_ID}` | ||
: `${CONST.DEFAULT_NUMBER_ID}`; | ||
children = ( | ||
<MoneyRequestAction | ||
// If originalMessage.iouReportID is set, this is a 1:1 IOU expense in a DM chat whose reportID is report.chatReportID | ||
chatReportID={ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ? report?.chatReportID ?? '' : reportID} | ||
chatReportID={ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ? report?.chatReportID ?? `${CONST.DEFAULT_NUMBER_ID}` : reportID} | ||
requestReportID={iouReportID} | ||
reportID={reportID} | ||
action={action} | ||
|
@@ -675,7 +677,7 @@ | |
children = ( | ||
<TripRoomPreview | ||
action={action} | ||
chatReportID={ReportActionsUtils.getOriginalMessage(action)?.linkedReportID ?? '-1'} | ||
chatReportID={ReportActionsUtils.getOriginalMessage(action)?.linkedReportID ?? `${CONST.DEFAULT_NUMBER_ID}`} | ||
isHovered={hovered} | ||
contextMenuAnchor={popoverAnchorRef.current} | ||
containerStyles={displayAsGroup ? [] : [styles.mt2]} | ||
|
@@ -689,7 +691,7 @@ | |
<ReportPreview | ||
iouReportID={ReportActionsUtils.getIOUReportIDFromReportActionPreview(action)} | ||
chatReportID={reportID} | ||
policyID={report?.policyID ?? '-1'} | ||
Check failure on line 694 in src/pages/home/report/PureReportActionItem.tsx
|
||
containerStyles={displayAsGroup ? [] : [styles.mt2]} | ||
action={action} | ||
isHovered={hovered} | ||
|
@@ -707,19 +709,19 @@ | |
<ShowContextMenuContext.Provider value={contextValue}> | ||
<TaskPreview | ||
style={displayAsGroup ? [] : [styles.mt1]} | ||
taskReportID={ReportActionsUtils.isAddCommentAction(action) ? ReportActionsUtils.getOriginalMessage(action)?.taskReportID?.toString() ?? '-1' : '-1'} | ||
Check failure on line 712 in src/pages/home/report/PureReportActionItem.tsx
|
||
chatReportID={reportID} | ||
action={action} | ||
isHovered={hovered} | ||
contextMenuAnchor={popoverAnchorRef.current} | ||
checkIfContextMenuActive={toggleContextMenuFromActiveReportAction} | ||
policyID={report?.policyID ?? '-1'} | ||
Check failure on line 718 in src/pages/home/report/PureReportActionItem.tsx
|
||
/> | ||
</ShowContextMenuContext.Provider> | ||
); | ||
} else if (ReportActionsUtils.isReimbursementQueuedAction(action)) { | ||
const linkedReport = ReportUtils.isChatThread(report) ? parentReport : report; | ||
const submitterDisplayName = LocalePhoneNumber.formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(personalDetails?.[linkedReport?.ownerAccountID ?? -1])); | ||
Check failure on line 724 in src/pages/home/report/PureReportActionItem.tsx
|
||
const paymentType = ReportActionsUtils.getOriginalMessage(action)?.paymentType ?? ''; | ||
|
||
children = ( | ||
|
@@ -1011,7 +1013,7 @@ | |
if (action.actionName === CONST.REPORT.ACTIONS.TYPE.CREATED) { | ||
const transactionID = ReportActionsUtils.isMoneyRequestAction(parentReportActionForTransactionThread) | ||
? ReportActionsUtils.getOriginalMessage(parentReportActionForTransactionThread)?.IOUTransactionID | ||
: '-1'; | ||
Check failure on line 1016 in src/pages/home/report/PureReportActionItem.tsx
|
||
|
||
return ( | ||
<ReportActionItemContentCreated | ||
|
@@ -1061,12 +1063,12 @@ | |
|
||
const iouReportID = | ||
ReportActionsUtils.isMoneyRequestAction(action) && ReportActionsUtils.getOriginalMessage(action)?.IOUReportID | ||
? (ReportActionsUtils.getOriginalMessage(action)?.IOUReportID ?? '').toString() | ||
Check failure on line 1066 in src/pages/home/report/PureReportActionItem.tsx
|
||
: '-1'; | ||
Check failure on line 1067 in src/pages/home/report/PureReportActionItem.tsx
|
||
const transactionsWithReceipts = getTransactionsWithReceipts(iouReportID); | ||
const isWhisper = whisperedTo.length > 0 && transactionsWithReceipts.length === 0; | ||
const whisperedToPersonalDetails = isWhisper | ||
? (Object.values(personalDetails ?? {}).filter((details) => whisperedTo.includes(details?.accountID ?? -1)) as OnyxTypes.PersonalDetails[]) | ||
Check failure on line 1071 in src/pages/home/report/PureReportActionItem.tsx
|
||
: []; | ||
const isWhisperOnlyVisibleByUser = isWhisper && isCurrentUserTheOnlyParticipant(whisperedTo); | ||
const displayNamesWithTooltips = isWhisper ? ReportUtils.getDisplayNamesWithTooltips(whisperedToPersonalDetails, isMultipleParticipant) : []; | ||
|
@@ -1074,7 +1076,15 @@ | |
return ( | ||
<PressableWithSecondaryInteraction | ||
ref={popoverAnchorRef} | ||
onPress={draftMessage === undefined ? onPress : undefined} | ||
onPress={() => { | ||
if (draftMessage === undefined) { | ||
onPress?.(); | ||
} | ||
if (!Keyboard.isVisible()) { | ||
return; | ||
} | ||
Keyboard.dismiss(); | ||
}} | ||
style={[action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && !isDeletedParentAction ? styles.pointerEventsNone : styles.pointerEventsAuto]} | ||
onPressIn={() => shouldUseNarrowLayout && DeviceCapabilities.canUseTouchScreen() && ControlSelection.block()} | ||
onPressOut={() => ControlSelection.unblock()} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daledah Why this changes are in this PR? Do main does not have this changes already, I assume when eslint rule is added all the refactoring is also made to app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not added in main. I tried to fix all errors, but turns out we need a lot (20-ish) of file changes. Do you think we should continue to make these changes or just ignore it and move on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://expensify.slack.com/archives/C01GTK53T8Q/p1734427537784129 so this is a new eslint which effects a lot of places. It looks like everyone is handling it in their own PR. @daledah Let's update the code according to eslint rule only in the file we are meant to originally change.