-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add onTooltipPress callback to various tooltip components #55454
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
Merged
puneetlath
merged 15 commits into
Expensify:main
from
ishpaul777:make-tooltips-pressable
Jan 23, 2025
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0dfd994
Add onTooltipPress callback to various tooltip components
ishpaul777 2d27d4c
Update educational tooltip style to conditionally apply pointer events
ishpaul777 f869bd4
move educational tooltip to save search three dot menu
ishpaul777 b4ec870
fix typing
ishpaul777 77ac032
fix eslint
ishpaul777 f0217bb
Merge branch 'main' into make-tooltips-pressable
ishpaul777 1bf9857
make suggested change
ishpaul777 b0cb26d
Merge branch 'Expensify:main' into make-tooltips-pressable
ishpaul777 d9d6b2a
lint fix
ishpaul777 dfd8604
Merge branch 'main' into make-tooltips-pressable
ishpaul777 085e6b7
fix as per review
ishpaul777 572a438
declare animated pressable as seperate component
ishpaul777 d4bfec3
rename Wrapper to AnimatedWrapper
ishpaul777 c181839
add comments to clarify handling of extra anchor refs in PopoverConte…
ishpaul777 fdd058a
add comments to clarify handling of extra anchor refs
ishpaul777 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,12 +10,12 @@ | |
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import ControlSelection from '@libs/ControlSelection'; | ||
import convertToLTR from '@libs/convertToLTR'; | ||
import * as DeviceCapabilities from '@libs/DeviceCapabilities'; | ||
Check failure on line 13 in src/components/MenuItem.tsx
|
||
import getButtonState from '@libs/getButtonState'; | ||
import Parser from '@libs/Parser'; | ||
import type {AvatarSource} from '@libs/UserUtils'; | ||
import variables from '@styles/variables'; | ||
import * as Session from '@userActions/Session'; | ||
Check failure on line 18 in src/components/MenuItem.tsx
|
||
import CONST from '@src/CONST'; | ||
import type {Icon as IconType} from '@src/types/onyx/OnyxCommon'; | ||
import type {TooltipAnchorAlignment} from '@src/types/utils/AnchorAlignment'; | ||
|
@@ -335,6 +335,9 @@ | |
/** Render custom content inside the tooltip. */ | ||
renderTooltipContent?: () => ReactNode; | ||
|
||
/** Callback to fire when the education tooltip is pressed */ | ||
onEducationTooltipPress?: () => void; | ||
|
||
shouldShowLoadingSpinnerIcon?: boolean; | ||
|
||
/** Should selected item be marked with checkmark */ | ||
|
@@ -459,6 +462,7 @@ | |
tooltipShiftHorizontal = 0, | ||
tooltipShiftVertical = 0, | ||
renderTooltipContent, | ||
onEducationTooltipPress, | ||
additionalIconStyles, | ||
shouldShowSelectedItemCheck = false, | ||
shouldIconUseAutoWidthStyle = false, | ||
|
@@ -601,6 +605,7 @@ | |
shiftHorizontal={tooltipShiftHorizontal} | ||
shiftVertical={tooltipShiftVertical} | ||
shouldTeleportPortalToModalLayer={shouldTeleportPortalToModalLayer} | ||
onTooltipPress={onEducationTooltipPress} | ||
> | ||
<View> | ||
<Hoverable> | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,11 +5,13 @@ | |
import * as Expensicons from '@components/Icon/Expensicons'; | ||
import PopoverMenu from '@components/PopoverMenu'; | ||
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback'; | ||
import EducationalTooltip from '@components/Tooltip/EducationalTooltip'; | ||
import Tooltip from '@components/Tooltip/PopoverAnchorTooltip'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useTheme from '@hooks/useTheme'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import * as Browser from '@libs/Browser'; | ||
Check failure on line 13 in src/components/ThreeDotsMenu/index.tsx
|
||
import variables from '@styles/variables'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import type ThreeDotsMenuProps from './types'; | ||
|
@@ -30,6 +32,8 @@ | |
shouldSetModalVisibility = true, | ||
disabled = false, | ||
hideProductTrainingTooltip, | ||
renderProductTrainingTooltipContent, | ||
shouldShowProductTrainingTooltip = false, | ||
}: ThreeDotsMenuProps) { | ||
const [modal] = useOnyx(ONYXKEYS.MODAL); | ||
|
||
|
@@ -55,27 +59,42 @@ | |
hidePopoverMenu(); | ||
}, [isBehindModal, isPopupMenuVisible]); | ||
|
||
const onThreeDotsPress = () => { | ||
if (isPopupMenuVisible) { | ||
hidePopoverMenu(); | ||
return; | ||
} | ||
hideProductTrainingTooltip?.(); | ||
buttonRef.current?.blur(); | ||
showPopoverMenu(); | ||
if (onIconPress) { | ||
onIconPress(); | ||
} | ||
}; | ||
|
||
const TooltipToRender = shouldShowProductTrainingTooltip ? EducationalTooltip : Tooltip; | ||
const tooltipProps = shouldShowProductTrainingTooltip | ||
? { | ||
renderTooltipContent: renderProductTrainingTooltipContent, | ||
shouldRender: shouldShowProductTrainingTooltip, | ||
anchorAlignment: { | ||
horizontal: CONST.MODAL.ANCHOR_ORIGIN_HORIZONTAL.RIGHT, | ||
vertical: CONST.MODAL.ANCHOR_ORIGIN_VERTICAL.BOTTOM, | ||
}, | ||
shiftHorizontal: variables.savedSearchShiftHorizontal, | ||
shiftVertical: variables.savedSearchShiftVertical, | ||
wrapperStyle: [styles.mh4, styles.pv2, styles.productTrainingTooltipWrapper], | ||
onTooltipPress: onThreeDotsPress, | ||
} | ||
: {text: translate(iconTooltip), shouldRender: true}; | ||
|
||
return ( | ||
<> | ||
<View> | ||
<Tooltip | ||
text={translate(iconTooltip)} | ||
// We need to hide the extra "More" tooltip when we have an educational tooltip | ||
shouldRender={!hideProductTrainingTooltip} | ||
> | ||
{/* eslint-disable-next-line react/jsx-props-no-spreading */} | ||
<TooltipToRender {...tooltipProps}> | ||
<PressableWithoutFeedback | ||
onPress={() => { | ||
if (isPopupMenuVisible) { | ||
hidePopoverMenu(); | ||
return; | ||
} | ||
hideProductTrainingTooltip?.(); | ||
buttonRef.current?.blur(); | ||
showPopoverMenu(); | ||
if (onIconPress) { | ||
onIconPress(); | ||
} | ||
}} | ||
onPress={onThreeDotsPress} | ||
disabled={disabled} | ||
onMouseDown={(e) => { | ||
/* Keep the focus state on mWeb like we did on the native apps. */ | ||
|
@@ -94,7 +113,7 @@ | |
fill={iconFill ?? isPopupMenuVisible ? theme.success : theme.icon} | ||
/> | ||
</PressableWithoutFeedback> | ||
</Tooltip> | ||
</TooltipToRender> | ||
</View> | ||
<PopoverMenu | ||
onClose={hidePopoverMenu} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.