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 focus is in edit report action after ctrl+k when delete confirm modal appears #36195

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading