Skip to content

Commit 2544c10

Browse files
authored
TestRunDetails. Diff toggles it not switched off in case no diff image present (#244)
closes Visual-Regression-Tracker/Visual-Regression-Tracker#316
1 parent 0bd5da3 commit 2544c10

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/components/TestDetailsDialog/TestDetailsModal.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const TestDetailsModal: React.FunctionComponent<{
8282
const [valueOfIgnoreOrCompare, setValueOfIgnoreOrCompare] = useState(
8383
"Ignore Areas"
8484
);
85-
const [isDiffShown, setIsDiffShown] = useState(!!testRun.diffName);
85+
const [isDiffShown, setIsDiffShown] = useState(false);
8686
const [selectedRectId, setSelectedRectId] = React.useState<string>();
8787
const [ignoreAreas, setIgnoreAreas] = React.useState<IgnoreArea[]>([]);
8888
const [applyIgnoreDialogOpen, setApplyIgnoreDialogOpen] = React.useState(
@@ -111,6 +111,10 @@ const TestDetailsModal: React.FunctionComponent<{
111111
// eslint-disable-next-line
112112
}, [image]);
113113

114+
React.useEffect(() => {
115+
setIsDiffShown(!!testRun.diffName);
116+
}, [testRun.diffName]);
117+
114118
React.useEffect(() => {
115119
setIgnoreAreas(JSON.parse(testRun.ignoreAreas));
116120
}, [testRun]);
@@ -250,11 +254,10 @@ const TestDetailsModal: React.FunctionComponent<{
250254

251255
useHotkeys(
252256
"d",
253-
() =>
254-
shouldDiffHotKeyBeActive && setIsDiffShown((isDiffShown) => !isDiffShown)
257+
() => !!testRun.diffName && setIsDiffShown((isDiffShown) => !isDiffShown),
258+
[testRun.diffName]
255259
);
256260
useHotkeys("ESC", handleClose, [handleClose]);
257-
const shouldDiffHotKeyBeActive = !!testRun.diffName;
258261

259262
return (
260263
<React.Fragment>
@@ -264,7 +267,7 @@ const TestDetailsModal: React.FunctionComponent<{
264267
<Grid item>
265268
<Typography variant="h6">{testRun.name}</Typography>
266269
</Grid>
267-
{shouldDiffHotKeyBeActive && (
270+
{testRun.diffName && (
268271
<Grid item>
269272
<Tooltip title={"Hotkey: D"}>
270273
<Switch

0 commit comments

Comments
 (0)