From 633b5651920a21b549877d36e0f388474c33c718 Mon Sep 17 00:00:00 2001 From: Arya Khochare <91268931+Aryakoste@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:42:55 +0530 Subject: [PATCH] migrate tooltips of file_preview_modal_main_actions.tsx to WithTooltip (#27243) --- .../file_preview_modal_main_actions.tsx | 43 +++++++------------ .../with_tooltip/create_tooltip.tsx | 1 + .../src/components/with_tooltip/index.tsx | 5 +++ 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/webapp/channels/src/components/file_preview_modal/file_preview_modal_main_actions/file_preview_modal_main_actions.tsx b/webapp/channels/src/components/file_preview_modal/file_preview_modal_main_actions/file_preview_modal_main_actions.tsx index dd5442c672..4794972a9f 100644 --- a/webapp/channels/src/components/file_preview_modal/file_preview_modal_main_actions/file_preview_modal_main_actions.tsx +++ b/webapp/channels/src/components/file_preview_modal/file_preview_modal_main_actions/file_preview_modal_main_actions.tsx @@ -12,10 +12,9 @@ import {getFilePublicLink as selectFilePublicLink} from 'mattermost-redux/select import CopyButton from 'components/copy_button'; import ExternalLink from 'components/external_link'; -import OverlayTrigger from 'components/overlay_trigger'; -import Tooltip from 'components/tooltip'; +import WithTooltip from 'components/with_tooltip'; -import Constants, {FileTypes} from 'utils/constants'; +import {FileTypes} from 'utils/constants'; import {copyToClipboard, getFileType} from 'utils/utils'; import type {GlobalState} from 'types/store'; @@ -63,15 +62,11 @@ const FilePreviewModalMainActions: React.FC = (props: Props) => { defaultMessage: 'Close', }); const closeButton = ( - - {closeMessage} - - } + key='publicLink' > - + ); let publicTooltipMessage; @@ -96,17 +91,13 @@ const FilePreviewModalMainActions: React.FC = (props: Props) => { }); } const publicLink = ( - setPublicLinkCopied(false)} - overlay={ - - {publicTooltipMessage} - - } > = (props: Props) => { > - + ); const downloadMessage = intl.formatMessage({ @@ -124,15 +115,11 @@ const FilePreviewModalMainActions: React.FC = (props: Props) => { defaultMessage: 'Download', }); const download = ( - - {downloadMessage} - - } + title={downloadMessage} > = (props: Props) => { > - + ); const copy = ( diff --git a/webapp/channels/src/components/with_tooltip/create_tooltip.tsx b/webapp/channels/src/components/with_tooltip/create_tooltip.tsx index 7446f95b45..f3817b1218 100644 --- a/webapp/channels/src/components/with_tooltip/create_tooltip.tsx +++ b/webapp/channels/src/components/with_tooltip/create_tooltip.tsx @@ -20,6 +20,7 @@ export type CommonTooltipProps = { shortcut?: ShortcutDefinition; emoji?: string; emojiStyle?: EmojiStyle; + shouldUpdatePosition?: boolean; } export function createTooltip(commonTooltipProps: CommonTooltipProps) { diff --git a/webapp/channels/src/components/with_tooltip/index.tsx b/webapp/channels/src/components/with_tooltip/index.tsx index 25bda6089e..b432e27e2b 100644 --- a/webapp/channels/src/components/with_tooltip/index.tsx +++ b/webapp/channels/src/components/with_tooltip/index.tsx @@ -17,6 +17,7 @@ type WithTooltipProps = { children: OverlayTriggerProps['children']; placement: OverlayTriggerProps['placement']; onShow?: () => void; + onExit?: () => void; } & CommonTooltipProps; const WithTooltip = ({ id, @@ -28,6 +29,8 @@ const WithTooltip = ({ placement, onShow, children, + onExit, + shouldUpdatePosition, }: WithTooltipProps) => { const ThisTooltip = useMemo(() => createTooltip({ id, @@ -44,6 +47,8 @@ const WithTooltip = ({ overlay={} placement={placement} onEnter={onShow} + onExit={onExit} + shouldUpdatePosition={shouldUpdatePosition} > {children}