diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx index f70b683339b8..127c6845d4d1 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.tsx @@ -53,7 +53,7 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef { - setInstanceID(Math.random().toString(36).slice(2, 7)); + instanceIDRef.current = Math.random().toString(36).slice(2, 7); onPopoverShow.current(); // After we have called the action, reset it. @@ -255,7 +255,7 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef, shouldSetModalVisibility?: boolean, onConfirm?: OnConfirm, onCancel?: OnCancel) => void; hideDeleteModal: () => void; isActiveReportAction: (accountID: string | number) => boolean; - instanceID: string; + instanceIDRef: RefObject; runAndResetOnPopoverHide: () => void; clearActiveReportAction: () => void; contentRef: RefObject; @@ -73,9 +73,9 @@ function hideContextMenu(shouldDelay?: boolean, onHideCallback = () => {}) { // Save the active instanceID for which hide action was called. // If menu is being closed with a delay, check that whether the same instance exists or a new was created. // If instance is not same, cancel the hide action - const instanceID = contextMenuRef.current.instanceID; + const instanceID = contextMenuRef.current.instanceIDRef.current; setTimeout(() => { - if (contextMenuRef.current?.instanceID !== instanceID) { + if (contextMenuRef.current?.instanceIDRef.current !== instanceID) { return; } @@ -151,7 +151,7 @@ function showContextMenu( // If there is an already open context menu, close it first before opening // a new one. - if (contextMenuRef.current.instanceID) { + if (contextMenuRef.current.instanceIDRef.current) { hideContextMenu(false, show); return; }