From 7884cafb68bd52b36bac0639c77f63adb597bc20 Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Mon, 14 Aug 2023 02:13:29 +0500 Subject: [PATCH 1/4] fix: popover without overlay changes --- src/CONST.js | 1 + src/components/PopoverProvider/index.js | 10 +++++++++- src/components/PopoverWithoutOverlay/index.js | 1 + .../ContextMenu/PopoverReportActionContextMenu.js | 4 ++-- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 4c19965837d9..7f00cf32b3a7 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -611,6 +611,7 @@ const CONST = { RIGHT: 'right', }, POPOVER_MENU_PADDING: 8, + POPOVER_ANCHOR_SHIFT: 2, }, TIMING: { CALCULATE_MOST_RECENT_LAST_MODIFIED_ACTION: 'calc_most_recent_last_modified_action', diff --git a/src/components/PopoverProvider/index.js b/src/components/PopoverProvider/index.js index e12e7a96e549..f9f6ce1d9f06 100644 --- a/src/components/PopoverProvider/index.js +++ b/src/components/PopoverProvider/index.js @@ -48,7 +48,15 @@ function PopoverContextProvider(props) { }, [closePopover]); React.useEffect(() => { - const listener = () => { + const listener = (e) => { + if ( + !activePopoverRef.current || + !activePopoverRef.current.ref || + !activePopoverRef.current.ref.current || + activePopoverRef.current.ref.current.contains(e.target) + ) { + return; + } closePopover(); }; document.addEventListener('contextmenu', listener); diff --git a/src/components/PopoverWithoutOverlay/index.js b/src/components/PopoverWithoutOverlay/index.js index d42f735b19a8..778f65349969 100644 --- a/src/components/PopoverWithoutOverlay/index.js +++ b/src/components/PopoverWithoutOverlay/index.js @@ -35,6 +35,7 @@ function Popover(props) { } else { props.onModalHide(); close(props.anchorRef); + Modal.onModalDidClose(); } Modal.willAlertModalBecomeVisible(props.isVisible); Modal.setCloseModal(props.isVisible ? () => props.onClose(props.anchorRef) : null); diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 81858564b416..756b8da32d58 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -165,8 +165,8 @@ class PopoverReportActionContextMenu extends React.Component { vertical: nativeEvent.pageY - y, }, popoverAnchorPosition: { - horizontal: nativeEvent.pageX, - vertical: nativeEvent.pageY, + horizontal: nativeEvent.pageX + CONST.MODAL.POPOVER_ANCHOR_SHIFT, + vertical: nativeEvent.pageY - CONST.MODAL.POPOVER_ANCHOR_SHIFT, }, type, reportID, From 23f3b491a68836d8c93a62ff58b8abc0052115e8 Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Mon, 14 Aug 2023 12:27:11 +0500 Subject: [PATCH 2/4] fix: lint errors --- src/components/PopoverProvider/index.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/components/PopoverProvider/index.js b/src/components/PopoverProvider/index.js index f9f6ce1d9f06..efa230d920d5 100644 --- a/src/components/PopoverProvider/index.js +++ b/src/components/PopoverProvider/index.js @@ -49,12 +49,7 @@ function PopoverContextProvider(props) { React.useEffect(() => { const listener = (e) => { - if ( - !activePopoverRef.current || - !activePopoverRef.current.ref || - !activePopoverRef.current.ref.current || - activePopoverRef.current.ref.current.contains(e.target) - ) { + if (!activePopoverRef.current || !activePopoverRef.current.ref || !activePopoverRef.current.ref.current || activePopoverRef.current.ref.current.contains(e.target)) { return; } closePopover(); From 00f6e4f2fbd040af91ad27aee851aa30d2326255 Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Tue, 22 Aug 2023 01:59:02 +0500 Subject: [PATCH 3/4] fix: revert changes for hover lost --- .../home/report/ContextMenu/PopoverReportActionContextMenu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 756b8da32d58..81858564b416 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -165,8 +165,8 @@ class PopoverReportActionContextMenu extends React.Component { vertical: nativeEvent.pageY - y, }, popoverAnchorPosition: { - horizontal: nativeEvent.pageX + CONST.MODAL.POPOVER_ANCHOR_SHIFT, - vertical: nativeEvent.pageY - CONST.MODAL.POPOVER_ANCHOR_SHIFT, + horizontal: nativeEvent.pageX, + vertical: nativeEvent.pageY, }, type, reportID, From 9ba77001903c244522ec7672a3004cec3b1a4c3a Mon Sep 17 00:00:00 2001 From: Sibtain Ali Date: Tue, 22 Aug 2023 02:01:09 +0500 Subject: [PATCH 4/4] fix: revert const changes --- src/CONST.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/CONST.js b/src/CONST.js index 7f00cf32b3a7..4c19965837d9 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -611,7 +611,6 @@ const CONST = { RIGHT: 'right', }, POPOVER_MENU_PADDING: 8, - POPOVER_ANCHOR_SHIFT: 2, }, TIMING: { CALCULATE_MOST_RECENT_LAST_MODIFIED_ACTION: 'calc_most_recent_last_modified_action',