Skip to content

Commit cd23afd

Browse files
authored
Merge pull request Expensify#90909 from margelo/@chrispader/composer-editing-regression-focus-highlight-after-delete
fix: Composer not highlighted after editing message
2 parents fd7b0b5 + 727a322 commit cd23afd

7 files changed

Lines changed: 13 additions & 22 deletions

File tree

src/libs/focusEditAfterCancelDelete/index.native.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/libs/focusEditAfterCancelDelete/index.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/libs/focusEditAfterCancelDelete/types.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/pages/inbox/report/PureReportActionItem.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,10 @@ function PureReportActionItem({
458458
const disabledActions = useMemo(() => (!canWriteInReport(report) ? RestrictedReadOnlyContextMenuActions : []), [report]);
459459

460460
const hasActionErrors = !isEmptyValueObject(action.errors);
461+
461462
// Receipt upload errors should still allow the context menu so the user can access "Delete expense"
462463
const hasOnlyReceiptErrors = hasActionErrors && Object.values(action.errors ?? {}).every((error) => error === null || isReceiptError(error));
464+
463465
const isContextMenuDisabled = useMemo(() => {
464466
return draftMessage !== undefined || (hasActionErrors && !hasOnlyReceiptErrors) || !shouldDisplayContextMenuValue;
465467
}, [draftMessage, hasActionErrors, hasOnlyReceiptErrors, shouldDisplayContextMenuValue]);

src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,10 @@ function ComposerWithSuggestions({
328328
focusComposerWithDelay(composerRef.current, delay)(shouldDelay, forcedSelectionRange, forceKeyboardIfAlreadyFocused).catch(() => {});
329329
}, []);
330330

331-
const handleEditFocus = useCallback(() => focus(true, undefined, true), [focus]);
331+
const handleEditFocus = useCallback(() => {
332+
focus(true, undefined, true);
333+
onFocus();
334+
}, [focus, onFocus]);
332335

333336
const handleEditValueChange = useCallback(
334337
(nextValue: string) => {

src/pages/inbox/report/ReportActionCompose/ExpandCollapseButton.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@ import useThemeStyles from '@hooks/useThemeStyles';
1111
import CONST from '@src/CONST';
1212

1313
type ExpandCollapseButtonProps = ViewProps & {
14+
/** Whether the full composer is available */
1415
isFullComposerAvailable: boolean;
16+
/** Whether the composer is full size */
1517
isComposerFullSize: boolean;
18+
/** The report ID */
1619
reportID: string;
20+
/** Function to raise the scroll is likely layout triggered */
1721
raiseIsScrollLikelyLayoutTriggered: () => void;
22+
/** Function to set the composer full size */
1823
setIsComposerFullSize: (reportID: string, isFullSize: boolean) => void;
24+
/** Whether the button is disabled */
1925
disabled?: boolean;
2026
};
2127

src/pages/inbox/report/ReportActionCompose/useEditMessage.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import useOnyx from '@hooks/useOnyx';
88
import useReportIsArchived from '@hooks/useReportIsArchived';
99
import useReportScrollManager from '@hooks/useReportScrollManager';
1010
import {clearAllReportActionDrafts, editReportComment} from '@libs/actions/Report';
11-
import focusEditAfterCancelDelete from '@libs/focusEditAfterCancelDelete';
1211
import {getOriginalReportID} from '@libs/ReportUtils';
1312
import * as ReportActionContextMenu from '@pages/inbox/report/ContextMenu/ReportActionContextMenu';
1413
import {useReportActionActiveEditActions} from '@pages/inbox/report/ReportActionEditMessageContext';
@@ -83,7 +82,7 @@ function useEditMessage({reportID, originalReportID, reportAction, shouldScrollT
8382
// When user tries to save the empty message, it will delete it. Prompt the user to confirm deleting.
8483
if (!trimmedNewDraft) {
8584
composerRef.current?.blur();
86-
ReportActionContextMenu.showDeleteModal(actionOwnerReportID, reportAction, true, deleteDraft, () => focusEditAfterCancelDelete(composerRef.current));
85+
ReportActionContextMenu.showDeleteModal(actionOwnerReportID, reportAction, true, deleteDraft, () => requestIdleCallback(() => composerRef.current?.focus()));
8786
return;
8887
}
8988

0 commit comments

Comments
 (0)