Skip to content

Commit

Permalink
Merge pull request #49538 from Shahidullah-Muffakir/fix/45472
Browse files Browse the repository at this point in the history
Fix focus loss after message deletion in edit mode
  • Loading branch information
youssef-lr authored Oct 10, 2024
2 parents 658239c + a5e6ef5 commit 0984f7d
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor
const onPopoverHide = useRef(() => {});
const onEmojiPickerToggle = useRef<undefined | ((state: boolean) => void)>();
const onCancelDeleteModal = useRef(() => {});
const onComfirmDeleteModal = useRef(() => {});
const onConfirmDeleteModal = useRef(() => {});

const onPopoverHideActionCallback = useRef(() => {});
const callbackWhenDeleteModalHide = useRef(() => {});
Expand Down Expand Up @@ -225,7 +225,7 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor

/** After Popover shows, call the registered onPopoverShow callback and reset it */
const runAndResetOnPopoverShow = () => {
setInstanceID(Math.random().toString(36).substr(2, 5));
setInstanceID(Math.random().toString(36).slice(2, 7));
onPopoverShow.current();

// After we have called the action, reset it.
Expand Down Expand Up @@ -264,7 +264,7 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor
};

const confirmDeleteAndHideModal = useCallback(() => {
callbackWhenDeleteModalHide.current = () => (onComfirmDeleteModal.current = runAndResetCallback(onComfirmDeleteModal.current));
callbackWhenDeleteModalHide.current = runAndResetCallback(onConfirmDeleteModal.current);
const reportAction = reportActionRef.current;
if (ReportActionsUtils.isMoneyRequestAction(reportAction)) {
const originalMessage = ReportActionsUtils.getOriginalMessage(reportAction);
Expand Down Expand Up @@ -294,8 +294,8 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor
/** Opens the Confirm delete action modal */
const showDeleteModal: ReportActionContextMenu['showDeleteModal'] = (reportID, reportAction, shouldSetModalVisibility = true, onConfirm = () => {}, onCancel = () => {}) => {
onCancelDeleteModal.current = onCancel;
onComfirmDeleteModal.current = onConfirm;

onConfirmDeleteModal.current = onConfirm;
reportIDRef.current = reportID;
reportActionRef.current = reportAction ?? null;

Expand Down

0 comments on commit 0984f7d

Please sign in to comment.