Skip to content

Commit 510a575

Browse files
committed
Switches to correct ID on page load
Signed-off-by: James Cocker <james.s.earth@gmail.com>
1 parent fa76d53 commit 510a575

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

galasa-ui/src/components/test-runs/test-run-details/3270Tab/TabFor3270.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@ export default function TabFor3270({
4747
// eslint-disable-next-line
4848
}, [highlightedRowId, is3270CurrentlySelected]);
4949

50-
// Get the 'terminalScreen' parameter
51-
useEffect(() => {
52-
if (is3270CurrentlySelected && highlightedRowId === '') {
53-
const url = new URL(window.location.href);
54-
console.log('Hello Set to ' + url.searchParams.get('terminalScreen'));
55-
setHighlightedRowId(url.searchParams.get('terminalScreen') || '');
56-
}
57-
58-
// If you're adding extra state to this hook, make sure to review the dependency array due to the warning suppression:
59-
// eslint-disable-next-line
60-
}, [is3270CurrentlySelected, isLoading]);
61-
6250
if (isError) {
6351
return <ErrorPage />;
6452
}

galasa-ui/src/components/test-runs/test-run-details/3270Tab/TableOfScreenshots.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ export default function TableOfScreenshots({
7878
const [searchTerm, setSearchTerm] = useState('');
7979
const [selectedTerminal, setSelectedTerminal] = useState<DropdownOption | null>(null);
8080
const [allImageData, setAllImageData] = useState<TerminalImage[]>([]);
81-
const [initialHighlightedRowSet, setInitialHighlightedRowSet] = useState<boolean>(false);
8281

8382
const screenshotsCollected = useRef<boolean | null>(false);
8483

@@ -116,12 +115,14 @@ export default function TableOfScreenshots({
116115
useEffect(() => {
117116
// Highlight and display first element when the page loads, unless already set.
118117
const highlightFirstRowOnPageLoad = () => {
119-
if (!initialHighlightedRowSet && filteredRows[0]) {
120-
setInitialHighlightedRowSet(true);
121-
if (
122-
highlightedRowId === '' ||
123-
!filteredRows.find((filteredRow) => filteredRow.id === highlightedRowId)
124-
) {
118+
if (!highlightedRowId && filteredRows[0]) {
119+
120+
const url = new URL(window.location.href);
121+
const terminalScreen = url.searchParams.get('terminalScreen');
122+
123+
if (terminalScreen && filteredRows.find((filteredRow) => filteredRow.id === terminalScreen)) {
124+
setHighlightedRowId(terminalScreen);
125+
} else {
125126
setHighlightedRowId(filteredRows[0].id);
126127
}
127128
}

0 commit comments

Comments
 (0)