Skip to content

Commit c4192af

Browse files
committed
fix: js doc comments & logic in tooltip
1 parent 1c6f9d0 commit c4192af

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/Common/Tooltip/Tooltip.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ const Tooltip = ({
2525
}
2626
}
2727

28-
return (!showOnTruncate || !isTextTruncated) && !alwaysShowTippyOnHover && !shortcutKeyCombo ? (
29-
cloneElement(child, { ...child.props, onMouseEnter: handleMouseEnterEvent })
30-
) : (
28+
const showTooltipWhenShortcutKeyComboProvided =
29+
!!shortcutKeyCombo && (alwaysShowTippyOnHover === undefined || alwaysShowTippyOnHover)
30+
const showTooltipOnTruncate = showOnTruncate && isTextTruncated
31+
32+
return showTooltipOnTruncate || showTooltipWhenShortcutKeyComboProvided || alwaysShowTippyOnHover ? (
3133
<TippyJS
3234
arrow={false}
3335
placement="top"
@@ -39,6 +41,8 @@ const Tooltip = ({
3941
>
4042
{cloneElement(child, { ...child.props, onMouseEnter: handleMouseEnterEvent })}
4143
</TippyJS>
44+
) : (
45+
cloneElement(child, { ...child.props, onMouseEnter: handleMouseEnterEvent })
4246
)
4347
}
4448

src/Common/Tooltip/types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type BaseTooltipProps =
2424
alwaysShowTippyOnHover?: never
2525
/**
2626
* If true, use the common styling for shortcuts
27-
* @default false
27+
* @default undefined
2828
*/
2929
shortcutKeyCombo?: never
3030
content: TippyProps['content']
@@ -42,7 +42,7 @@ type BaseTooltipProps =
4242
alwaysShowTippyOnHover?: boolean
4343
/**
4444
* If true, use the common styling for shortcuts
45-
* @default false
45+
* @default undefined
4646
*/
4747
shortcutKeyCombo?: never
4848
content: TippyProps['content']
@@ -60,13 +60,13 @@ type BaseTooltipProps =
6060
alwaysShowTippyOnHover?: boolean
6161
/**
6262
* If true, use the common styling for shortcuts
63-
* @default true
63+
* @default undefined
6464
*/
65-
content?: never
6665
shortcutKeyCombo?: {
6766
text: string
6867
combo: SupportedKeyboardKeysType[]
6968
}
69+
content?: never
7070
}
7171

7272
export type TooltipProps = BaseTooltipProps &

src/Shared/Components/CICDHistory/History.components.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export const LogResizeButton = withShortcut(
4545
const { pathname } = useLocation()
4646

4747
const toggleFullScreen = useCallback((): void => {
48-
// NOTE: need to use ref due to the problem of stale function reference after registering the callback
4948
setFullScreenView(!fullScreenView)
5049
}, [fullScreenView])
5150

@@ -101,7 +100,7 @@ export const LogResizeButton = withShortcut(
101100

102101
export const Scroller = ({ scrollToTop, scrollToBottom, style }: ScrollerType): JSX.Element => (
103102
<div style={style} className="dc__element-scroller flex column top br-4">
104-
<Tooltip content="Scroll to Top" placement="left">
103+
<Tooltip alwaysShowTippyOnHover content="Scroll to Top" placement="left">
105104
<button
106105
className="flex"
107106
disabled={!scrollToTop}
@@ -112,7 +111,7 @@ export const Scroller = ({ scrollToTop, scrollToBottom, style }: ScrollerType):
112111
<DropDownIcon className="rotate" style={{ ['--rotateBy' as any]: '180deg' }} />
113112
</button>
114113
</Tooltip>
115-
<Tooltip content="Scroll to Bottom" placement="left">
114+
<Tooltip alwaysShowTippyOnHover content="Scroll to Bottom" placement="left">
116115
<button
117116
className="flex"
118117
disabled={!scrollToBottom}

0 commit comments

Comments
 (0)