LandingPage: Fixes tabs selection on browser back/forward.

In the context of HMS-parity with edge management, fixes the current behavior when using browser history back and forward.
- When selecting a tab and then push the browser history back/forward, the tab of the current url is selected.

FIXES: https://issues.redhat.com/browse/THEEDGE-3460
This commit is contained in:
Djebran Lezzoum 2023-07-13 10:07:46 +02:00 committed by Klara Simickova
parent ea89a92bf1
commit e726ddc2a1

View file

@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import {
Alert,
@ -50,6 +50,9 @@ export const LandingPage = () => {
const initialActiveTabKey =
tabsPath.indexOf(pathname) >= 0 ? tabsPath.indexOf(pathname) : 0;
const [activeTabKey, setActiveTabKey] = useState(initialActiveTabKey);
useEffect(() => {
setActiveTabKey(initialActiveTabKey);
}, [pathname]);
const handleTabClick = (_event, tabIndex) => {
const tabPath = tabsPath[tabIndex];
if (tabPath !== undefined) {