Skip to content

Commit

Permalink
fix(ui): Bring back tooltip arrows (#82241)
Browse files Browse the repository at this point in the history
  • Loading branch information
scttcper authored Dec 17, 2024
1 parent 578f2af commit 63fc159
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
13 changes: 12 additions & 1 deletion static/app/components/tooltip.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,23 @@ describe('Tooltip', function () {
jest.clearAllMocks();
});

it('renders', function () {
it('renders', async function () {
render(
<Tooltip delay={0} title="test">
<span>My Button</span>
</Tooltip>
);

await userEvent.hover(screen.getByText('My Button'));
expect(screen.getByText('test')).toBeInTheDocument();

// Check that the arrow svg is rendered
expect(document.querySelector('svg')).toBeInTheDocument();

await userEvent.unhover(screen.getByText('My Button'));
await waitFor(() => {
expect(screen.queryByText('test')).not.toBeInTheDocument();
});
});

it('updates title', async function () {
Expand Down
7 changes: 3 additions & 4 deletions static/app/components/tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {createContext, Fragment, useContext, useEffect} from 'react';
import {createPortal} from 'react-dom';
import isPropValid from '@emotion/is-prop-valid';
import type {SerializedStyles} from '@emotion/react';
import {useTheme} from '@emotion/react';
import styled from '@emotion/styled';
Expand Down Expand Up @@ -92,9 +91,9 @@ function Tooltip({
);
}

const TooltipContent = styled(Overlay, {shouldForwardProp: isPropValid})<{
maxWidth?: number;
}>`
const TooltipContent = styled(Overlay, {
shouldForwardProp: prop => prop !== 'maxWidth',
})<{maxWidth?: number}>`
padding: ${space(1)} ${space(1.5)};
overflow-wrap: break-word;
max-width: ${p => p.maxWidth ?? 225}px;
Expand Down

0 comments on commit 63fc159

Please sign in to comment.