Skip to content

Commit 9ee499e

Browse files
authored
fix(canvas): raw tooltip shows up when hovering block params (#5589)
* fix(canvas): replace native title tooltip with styled overflow tooltip on block params Hovering a truncated subblock value or block name on the canvas popped the browser's raw native tooltip with the full untruncated content (including raw code). Replace the `title` attribute with the cursor-following styled Tooltip, shown only when the text is actually clipped. * fix(canvas): drop unused ResizeObserver in OverflowSpan useFloatingTooltip's canShow already receives the hovered element, so measuring overflow via useIsOverflowing was redundant — every canvas row was paying for a ResizeObserver and resize listener it never used.
1 parent f3582ed commit 9ee499e

3 files changed

Lines changed: 36 additions & 15 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { FloatingTooltip, isTextClipped, useFloatingTooltip } from '@sim/emcn'
2+
3+
interface OverflowSpanProps {
4+
value: string
5+
className: string
6+
}
7+
8+
/**
9+
* Truncated span that reveals its full value in a floating tooltip when — and
10+
* only when — the text is actually clipped. Never use a native `title`
11+
* attribute here: on the canvas it pops the browser's raw, unstyled tooltip
12+
* with the full untruncated value (including raw code/JSON) over the graph.
13+
*/
14+
export function OverflowSpan({ value, className }: OverflowSpanProps) {
15+
const { state, handlers } = useFloatingTooltip(isTextClipped)
16+
17+
return (
18+
<>
19+
<span className={className} {...handlers}>
20+
{value}
21+
</span>
22+
<FloatingTooltip label={value} state={state} />
23+
</>
24+
)
25+
}

packages/workflow-renderer/src/workflow-block/sub-block-row-view.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { cn } from '@sim/emcn'
2+
import { OverflowSpan } from '../lib/overflow-span'
23

34
/**
45
* Props for the pure subblock summary row. The container resolves the value —
@@ -22,22 +23,18 @@ export interface SubBlockRowViewProps {
2223
export function SubBlockRowView({ title, displayValue, isMonospace }: SubBlockRowViewProps) {
2324
return (
2425
<div className='flex items-center gap-2'>
25-
<span
26+
<OverflowSpan
27+
value={title}
2628
className='min-w-0 truncate text-[var(--text-tertiary)] text-sm capitalize'
27-
title={title}
28-
>
29-
{title}
30-
</span>
29+
/>
3130
{displayValue !== undefined && (
32-
<span
31+
<OverflowSpan
32+
value={displayValue}
3333
className={cn(
3434
'flex-1 truncate text-right text-[var(--text-primary)] text-sm',
3535
isMonospace && 'font-mono'
3636
)}
37-
title={displayValue}
38-
>
39-
{displayValue}
40-
</span>
37+
/>
4138
)}
4239
</div>
4340
)

packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ComponentType, ReactNode, Ref } from 'react'
22
import { Badge, cn, handleKeyboardActivation, Tooltip } from '@sim/emcn'
33
import { Handle, Position } from 'reactflow'
44
import { HANDLE_POSITIONS } from '../dimensions'
5+
import { OverflowSpan } from '../lib/overflow-span'
56
import { tileIconColorClass } from '../lib/tile-icon-color'
67
import type { BlockRunStatus } from '../types'
78
import { SubBlockRowView } from './sub-block-row-view'
@@ -212,15 +213,13 @@ export function WorkflowBlockView({
212213
)}
213214
/>
214215
</div>
215-
<span
216+
<OverflowSpan
217+
value={name}
216218
className={cn(
217219
'truncate font-medium text-md',
218220
!isEnabled && runPathStatus !== 'success' && 'text-[var(--text-muted)]'
219221
)}
220-
title={name}
221-
>
222-
{name}
223-
</span>
222+
/>
224223
</div>
225224
<div className='relative z-10 flex flex-shrink-0 items-center gap-1'>
226225
{isWorkflowSelector &&

0 commit comments

Comments
 (0)