Skip to content

Commit f08ae61

Browse files
authored
RI-7226: fix RiTooltip when title/content is empty (#4747)
* RI-7226: fix RiTooltip when title/content is empty * update test name
1 parent 2e64134 commit f08ae61

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

redisinsight/ui/src/components/base/tooltip/RITooltip.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ export const RiTooltip = ({
2323
<TooltipProvider>
2424
<Tooltip
2525
{...props}
26-
content={content && <HoverContent title={title} content={content} />}
26+
content={
27+
(content || title) && <HoverContent title={title} content={content} />
28+
}
2729
placement={position}
2830
openDelayDuration={delay}
2931
>

redisinsight/ui/src/components/base/tooltip/RiTooltip.spec.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ describe('RiTooltip', () => {
6262
expect(screen.queryByRole('heading')).not.toBeInTheDocument()
6363
})
6464

65-
it('should not render tooltip when content is not provided', async () => {
65+
it('should not render tooltip when content and title are not provided', async () => {
6666
render(
67-
<RiTooltip title="Test Title">
67+
<RiTooltip>
6868
<TestButton />
6969
</RiTooltip>,
7070
)
@@ -119,8 +119,12 @@ describe('RiTooltip', () => {
119119
})
120120
await waitForRiTooltipVisible()
121121

122-
expect(screen.getAllByTestId('tooltip-custom-content')[0]).toBeInTheDocument()
123-
expect(screen.getAllByText('Custom content with HTML')[0]).toBeInTheDocument()
122+
expect(
123+
screen.getAllByTestId('tooltip-custom-content')[0],
124+
).toBeInTheDocument()
125+
expect(
126+
screen.getAllByText('Custom content with HTML')[0],
127+
).toBeInTheDocument()
124128
expect(
125129
screen.getAllByRole('button', { name: 'Hover me' })[0],
126130
).toBeInTheDocument()

0 commit comments

Comments
 (0)