diff --git a/packages/trace-viewer/src/ui/attachmentsTab.tsx b/packages/trace-viewer/src/ui/attachmentsTab.tsx index 8b6cefe14df709..69bfcd68cce2f8 100644 --- a/packages/trace-viewer/src/ui/attachmentsTab.tsx +++ b/packages/trace-viewer/src/ui/attachmentsTab.tsx @@ -20,7 +20,7 @@ import { ImageDiffView } from '@web/shared/imageDiffView'; import type { MultiTraceModel } from './modelUtil'; import { PlaceholderPanel } from './placeholderPanel'; import type { AfterActionTraceEventAttachment } from '@trace/trace'; -import { CodeMirrorWrapper } from '@web/components/codeMirrorWrapper'; +import { CodeMirrorWrapper, lineHeight } from '@web/components/codeMirrorWrapper'; import { isTextualMimeType } from '@isomorphic/mimeType'; import { Expandable } from '@web/components/expandable'; import { linkifyText } from '@web/renderUtils'; @@ -51,6 +51,11 @@ const ExpandableAttachment: React.FunctionComponent = } }, [expanded, attachmentText, placeholder, attachment]); + const snippetHeight = React.useMemo(() => { + const lineCount = attachmentText ? attachmentText.split('\n').length : 0; + return Math.min(Math.max(5, lineCount), 20) * lineHeight; + }, [attachmentText]); + const title = {linkifyText(attachment.name)} {hasContent && download} ; @@ -62,14 +67,16 @@ const ExpandableAttachment: React.FunctionComponent = {placeholder && {placeholder}} - {expanded && attachmentText !== null && - } + {expanded && attachmentText !== null &&
+ + +
} ; };