Skip to content
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

Merged
merged 8 commits into from
Jan 8, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions src/pages/home/report/PureReportActionItem.tsx
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';
Expand Down Expand Up @@ -296,7 +296,7 @@
}: PureReportActionItemProps) {
const {translate} = useLocalize();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const reportID = report?.reportID ?? '';
const reportID = report?.reportID ?? `${CONST.DEFAULT_NUMBER_ID}`;
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
Expand Down Expand Up @@ -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,
Expand All @@ -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()) {
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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}
Expand All @@ -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]}
Expand All @@ -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

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

containerStyles={displayAsGroup ? [] : [styles.mt2]}
action={action}
isHovered={hovered}
Expand All @@ -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

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Check failure on line 712 in src/pages/home/report/PureReportActionItem.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

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

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

/>
</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

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

const paymentType = ReportActionsUtils.getOriginalMessage(action)?.paymentType ?? '';

children = (
Expand Down Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / Changed files ESLint check


return (
<ReportActionItemContentCreated
Expand Down Expand Up @@ -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

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

: '-1';

Check failure on line 1067 in src/pages/home/report/PureReportActionItem.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

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

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

: [];
const isWhisperOnlyVisibleByUser = isWhisper && isCurrentUserTheOnlyParticipant(whisperedTo);
const displayNamesWithTooltips = isWhisper ? ReportUtils.getDisplayNamesWithTooltips(whisperedToPersonalDetails, isMultipleParticipant) : [];
Expand All @@ -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()}
Expand Down
Loading