fix(html): prevent image diff from flickering (#11184)
This commit is contained in:
parent
e1772f15b5
commit
16dafba153
|
|
@ -122,16 +122,23 @@ const ImageDiff: React.FunctionComponent<{
|
|||
diff?: TestAttachment,
|
||||
}> = ({ actual, expected, diff }) => {
|
||||
const [selectedTab, setSelectedTab] = React.useState<string>('actual');
|
||||
const diffElement = React.useRef<HTMLImageElement>(null);
|
||||
const tabs = [];
|
||||
tabs.push({
|
||||
id: 'actual',
|
||||
title: 'Actual',
|
||||
render: () => <img src={actual.path}/>
|
||||
render: () => <img src={actual.path} onLoad={() => {
|
||||
if (diffElement.current)
|
||||
diffElement.current.style.minHeight = diffElement.current.offsetHeight + 'px';
|
||||
}}/>
|
||||
});
|
||||
tabs.push({
|
||||
id: 'expected',
|
||||
title: 'Expected',
|
||||
render: () => <img src={expected.path}/>
|
||||
render: () => <img src={expected.path} onLoad={() => {
|
||||
if (diffElement.current)
|
||||
diffElement.current.style.minHeight = diffElement.current.offsetHeight + 'px';
|
||||
}}/>
|
||||
});
|
||||
if (diff) {
|
||||
tabs.push({
|
||||
|
|
@ -140,7 +147,7 @@ const ImageDiff: React.FunctionComponent<{
|
|||
render: () => <img src={diff.path}/>
|
||||
});
|
||||
}
|
||||
return <div className='vbox' data-testid='test-result-image-mismatch'>
|
||||
return <div className='vbox' data-testid='test-result-image-mismatch' ref={diffElement}>
|
||||
<TabbedPane tabs={tabs} selectedTab={selectedTab} setSelectedTab={setSelectedTab} />
|
||||
</div>;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue