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 loss after message deletion in edit mode #49538

Merged
merged 4 commits into from
Oct 10, 2024
Merged
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
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
Loading