Skip to content

Commit

Permalink
Merge pull request #36195 from tsa321/wrFocusWhCJ
Browse files Browse the repository at this point in the history
Fix focus is in edit report action after ctrl+k when delete confirm modal appears
  • Loading branch information
Hayata Suenaga authored Feb 13, 2024
2 parents 6d7d8c0 + b7a50db commit 441c612
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
8 changes: 8 additions & 0 deletions src/libs/focusEditAfterCancelDelete/index.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {InteractionManager} from 'react-native';
import type FocusEditAfterCancelDelete from './types';

const focusEditAfterCancelDelete: FocusEditAfterCancelDelete = (textInputRef) => {
InteractionManager.runAfterInteractions(() => textInputRef?.focus());
};

export default focusEditAfterCancelDelete;
5 changes: 5 additions & 0 deletions src/libs/focusEditAfterCancelDelete/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type FocusEditAfterCancelDelete from './types';

const focusEditAfterCancelDelete: FocusEditAfterCancelDelete = () => {};

export default focusEditAfterCancelDelete;
5 changes: 5 additions & 0 deletions src/libs/focusEditAfterCancelDelete/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type {TextInput} from 'react-native';

type FocusEditAfterCancelDelete = (inputRef: TextInput | HTMLTextAreaElement | null) => void;

export default FocusEditAfterCancelDelete;
12 changes: 3 additions & 9 deletions src/pages/home/report/ReportActionItemMessageEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Str from 'expensify-common/lib/str';
import lodashDebounce from 'lodash/debounce';
import type {ForwardedRef} from 'react';
import React, {forwardRef, useCallback, useEffect, useMemo, useRef, useState} from 'react';
import {InteractionManager, Keyboard, View} from 'react-native';
import {Keyboard, View} from 'react-native';
import type {NativeSyntheticEvent, TextInput, TextInputFocusEventData, TextInputKeyPressEventData} from 'react-native';
import type {Emoji} from '@assets/emojis/types';
import Composer from '@components/Composer';
Expand All @@ -25,6 +25,7 @@ import * as Browser from '@libs/Browser';
import * as ComposerUtils from '@libs/ComposerUtils';
import * as EmojiUtils from '@libs/EmojiUtils';
import focusComposerWithDelay from '@libs/focusComposerWithDelay';
import focusEditAfterCancelDelete from '@libs/focusEditAfterCancelDelete';
import onyxSubscribe from '@libs/onyxSubscribe';
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
Expand Down Expand Up @@ -317,14 +318,7 @@ function ReportActionItemMessageEdit(
// When user tries to save the empty message, it will delete it. Prompt the user to confirm deleting.
if (!trimmedNewDraft) {
textInputRef.current?.blur();
ReportActionContextMenu.showDeleteModal(
reportID,
action,
true,
deleteDraft,
// eslint-disable-next-line @typescript-eslint/no-misused-promises
() => InteractionManager.runAfterInteractions(() => textInputRef.current?.focus()),
);
ReportActionContextMenu.showDeleteModal(reportID, action, true, deleteDraft, () => focusEditAfterCancelDelete(textInputRef.current));
return;
}
Report.editReportComment(reportID, action, trimmedNewDraft);
Expand Down

0 comments on commit 441c612

Please sign in to comment.