-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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: Pin & Delete request appear on Receipt image when quickly tap on receipt and 3-Dot menu #34720
Changes from 3 commits
00e958e
ed4bd8e
b9dcb28
7013594
dde9079
a1ebabc
63edee6
74c06a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import React, {useRef, useState} from 'react'; | ||
import React, {useEffect, useRef, useState} from 'react'; | ||
import type {StyleProp, ViewStyle} from 'react-native'; | ||
import {View} from 'react-native'; | ||
import type {OnyxEntry} from 'react-native-onyx'; | ||
import {withOnyx} from 'react-native-onyx'; | ||
import Icon from '@components/Icon'; | ||
import * as Expensicons from '@components/Icon/Expensicons'; | ||
import type {AnchorAlignment} from '@components/Popover/types'; | ||
|
@@ -14,10 +16,17 @@ import useThemeStyles from '@hooks/useThemeStyles'; | |
import * as Browser from '@libs/Browser'; | ||
import CONST from '@src/CONST'; | ||
import type {TranslationPaths} from '@src/languages/types'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type {AnchorPosition} from '@src/styles'; | ||
import type {Modal} from '@src/types/onyx'; | ||
import type IconAsset from '@src/types/utils/IconAsset'; | ||
|
||
type ThreeDotsMenuProps = { | ||
type ThreeDotsMenuOnyxProps = { | ||
/** Details about any modals being used */ | ||
modal: OnyxEntry<Modal>; | ||
}; | ||
|
||
type ThreeDotsMenuProps = ThreeDotsMenuOnyxProps & { | ||
/** Tooltip for the popup icon */ | ||
iconTooltip?: TranslationPaths; | ||
|
||
|
@@ -67,12 +76,14 @@ function ThreeDotsMenu({ | |
shouldOverlay = false, | ||
shouldSetModalVisibility = true, | ||
disabled = false, | ||
modal = {}, | ||
}: ThreeDotsMenuProps) { | ||
const theme = useTheme(); | ||
const styles = useThemeStyles(); | ||
const [isPopupMenuVisible, setPopupMenuVisible] = useState(false); | ||
const buttonRef = useRef(null); | ||
const {translate} = useLocalize(); | ||
const isBehindModal = modal?.willAlertModalBecomeVisible && !modal?.isPopover && !shouldOverlay; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: In here
I think if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. although we have default value There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant at line 86 const isBehindModal = modal?.willAlertModalBecomeVisible && !modal?.isPopover && !shouldOverlay; it will reach to checking It is a non issue and a very minor nitpick anyway 😁 . Need not be changed. |
||
|
||
const showPopoverMenu = () => { | ||
setPopupMenuVisible(true); | ||
|
@@ -82,6 +93,13 @@ function ThreeDotsMenu({ | |
setPopupMenuVisible(false); | ||
}; | ||
|
||
useEffect(() => { | ||
if (!isBehindModal || !isPopupMenuVisible) { | ||
return; | ||
} | ||
hidePopoverMenu(); | ||
}, [isBehindModal, isPopupMenuVisible]); | ||
|
||
return ( | ||
<> | ||
<View> | ||
|
@@ -119,7 +137,7 @@ function ThreeDotsMenu({ | |
</View> | ||
<PopoverMenu | ||
onClose={hidePopoverMenu} | ||
isVisible={isPopupMenuVisible} | ||
isVisible={isPopupMenuVisible && !isBehindModal} | ||
anchorPosition={anchorPosition} | ||
anchorAlignment={anchorAlignment} | ||
onItemSelected={hidePopoverMenu} | ||
|
@@ -134,4 +152,8 @@ function ThreeDotsMenu({ | |
|
||
ThreeDotsMenu.displayName = 'ThreeDotsMenu'; | ||
|
||
export default ThreeDotsMenu; | ||
export default withOnyx<ThreeDotsMenuProps, ThreeDotsMenuOnyxProps>({ | ||
modal: { | ||
key: ONYXKEYS.MODAL, | ||
}, | ||
})(ThreeDotsMenu); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,8 +54,8 @@ function setModalVisibility(isVisible: boolean) { | |
* Allows other parts of app to know that an alert modal is about to open. | ||
* This will trigger as soon as a modal is opened but not yet visible while animation is running. | ||
*/ | ||
function willAlertModalBecomeVisible(isVisible: boolean) { | ||
Onyx.merge(ONYXKEYS.MODAL, {willAlertModalBecomeVisible: isVisible}); | ||
function willAlertModalBecomeVisible(isVisible: boolean, isPopover = false) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add comment for why this param isPopover is required. |
||
Onyx.merge(ONYXKEYS.MODAL, {willAlertModalBecomeVisible: isVisible, isPopover}); | ||
} | ||
|
||
export {setCloseModal, close, onModalDidClose, setModalVisibility, willAlertModalBecomeVisible}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this new prop? Isn't it redundant with the
type
prop?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yah, I think we can remove it and use type. Thank you