Skip to content

Commit ee5b023

Browse files
authored
fix(web): prevent narrow session tooltips (#1114)
1 parent 8c1d505 commit ee5b023

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

web/src/components/HoverTooltip.test.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ import {
99
afterEach(() => cleanup())
1010

1111
describe('HoverTooltip keyboard wiring', () => {
12+
it('sizes short localized tooltips to their content up to the maximum width', () => {
13+
render(
14+
<HoverTooltip id="attention-tooltip" target={<span>dot</span>}>
15+
有新活动
16+
</HoverTooltip>
17+
)
18+
19+
const tooltip = screen.getByRole('tooltip', { hidden: true })
20+
expect(tooltip.className).toContain('w-max')
21+
expect(tooltip.className).toContain('max-w-[14rem]')
22+
})
23+
1224
it('applies parent row focus-visible reveal classes', () => {
1325
render(
1426
<HoverTooltip

web/src/components/HoverTooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function HoverTooltip(props: {
7272
id={props.id}
7373
className={cn(
7474
'pointer-events-none absolute z-30 whitespace-normal',
75-
spansRow ? 'max-w-none' : 'max-w-[14rem]',
75+
spansRow ? 'max-w-none' : 'w-max max-w-[14rem]',
7676
'rounded-md border border-[var(--app-border)] bg-[var(--app-secondary-bg)]',
7777
'px-2 py-1 text-xs leading-snug text-[var(--app-fg)] shadow-lg',
7878
side === 'top' ? 'bottom-full mb-1' : 'top-full mt-1',

0 commit comments

Comments
 (0)